Skip to content

Commit

Permalink
fix: update person details when mgt-person attributes are changed (#2871
Browse files Browse the repository at this point in the history
)

fix bug in changing mgt-person attributes

---------

Co-authored-by: Sébastien Levert <[email protected]>
  • Loading branch information
Mnickii and sebastienlevert authored Dec 11, 2023
1 parent 1796b6b commit 9c53cbf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/mgt-components/src/components/mgt-person/mgt-person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export class MgtPerson extends MgtTemplatedComponent {
}

this._personQuery = value;
this.personDetailsInternal = null;
this._personDetailsInternal = null;
this._personDetails = null;
void this.requestStateUpdate();
}

Expand Down Expand Up @@ -203,7 +204,8 @@ export class MgtPerson extends MgtTemplatedComponent {
}

this._userId = value;
this.personDetailsInternal = null;
this._personDetailsInternal = null;
this._personDetails = null;
void this.requestStateUpdate();
}

Expand Down Expand Up @@ -273,7 +275,6 @@ export class MgtPerson extends MgtTemplatedComponent {
this._fetchedPresence = null;

void this.requestStateUpdate();
this.requestUpdate('personDetailsInternal');
}

/**
Expand All @@ -299,7 +300,6 @@ export class MgtPerson extends MgtTemplatedComponent {
this._fetchedPresence = null;

void this.requestStateUpdate();
this.requestUpdate('personDetails');
}

/**
Expand All @@ -321,9 +321,7 @@ export class MgtPerson extends MgtTemplatedComponent {
}

this._isInvalidImageSrc = !value;
const oldValue = this._personImage;
this._personImage = value;
this.requestUpdate('personImage', oldValue);
}

/**
Expand Down
26 changes: 26 additions & 0 deletions stories/components/person/person.properties.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ export const setPersonDetails = () => html`
</script>
`;

export const changePersonQuery = () => html`
<mgt-person class="my-person" person-query="me" view="threelines"></mgt-person>
<button class="button">Change person-query </button>
<script>
const person = document.querySelector('.my-person');
const button = document.querySelector('.button');
button.addEventListener('click', () => {
person.personQuery = 'Isaiah';
});
</script>
`;

export const changeUserId = () => html`
<mgt-person class="my-person" person-query="me" view="threelines"></mgt-person>
<button class="button">Change user-id </button>
<script>
const person = document.querySelector('.my-person');
const button = document.querySelector('.button');
button.addEventListener('click', () => {
person.userId = '2804bc07-1e1f-4938-9085-ce6d756a32d2';
});
</script>
`;

export const personFallbackDetails = () => html`
<div class="example">
<mgt-person person-query="mbowen" view="twoLines" show-presence fallback-details='{"displayName":"Megan Bowen"}'></mgt-person>
Expand Down

0 comments on commit 9c53cbf

Please sign in to comment.