0

I'm using the @microsoft/live-share library in a React application to allow for collaborative editing. One feature I need to implement is the ability to react to changes in the user's role (e.g., if a user is an attendee to a presenter or organizer, one component will be disable for them).

What I use is the LivePresence component which can return the current user role. However, it appears that once the user role is determined during initialization, it cannot be changed, and the presenceChanged event does not seem to detect changes in the userRole.

Is there a way to detect and update the changes in the userRole with this library automatically? If not, are there any suggested workarounds to enable reacting to changes in the userRole? Any guidance or direction would be greatly appreciated.

Below is a snippet of my code where I attempt to handle role changes:


// ... existing code ...

presence.on("presenceChanged", (user: LivePresenceUser<ICustomUserData>, local: boolean) => {
    // I would like to react to changes in `user.roles` here
    console.log("Listener triggered");
    this.setState({ presence }, () => console.log("Updated state", this.state));
});

Thanks in advance for your help!

HTTOM
  • 1
  • Please have look into this sample-https://github.com/microsoft/live-share-sdk/blob/ee9643fee91dd1627727da6b9ebd19753f6b0bec/samples/typescript/21.react-media-template/src/live-share-hooks/usePresence.ts – Sayali-MSFT Jul 24 '23 at 10:16

0 Answers0