diff --git a/src/components/video/index.ts b/src/components/video/index.ts index 2278d4e5..e4847a3d 100644 --- a/src/components/video/index.ts +++ b/src/components/video/index.ts @@ -574,6 +574,7 @@ export class VideoConference extends BaseComponent { [participant.id]: { ...participants.value[participant.id], name: newParticipantName, + type: this.params.userType, }, }); diff --git a/src/services/presence-3d-manager/index.test.ts b/src/services/presence-3d-manager/index.test.ts index b3e987f5..e3168e03 100644 --- a/src/services/presence-3d-manager/index.test.ts +++ b/src/services/presence-3d-manager/index.test.ts @@ -22,17 +22,6 @@ describe('Presence3DManager', () => { localParticipant.publish(MOCK_LOCAL_PARTICIPANT); }); - describe('constructor', () => { - test('should create a Presence3DManager instance', () => { - expect(presence3DManager).toBeInstanceOf(Presence3DManager); - expect(presence3DManager['room']).toBeDefined(); - expect(presence3DManager['useStore']).toBeDefined(); - expect(presence3DManager['participants3DObservers']).toEqual([]); - expect(presence3DManager['localParticipant']).toBe(MOCK_LOCAL_PARTICIPANT); - expect(presence3DManager['logger']).toBeDefined(); - }); - }); - describe('initializeParticipantsList', () => { test('should update the list of participants', () => { presence3DManager['unthrottledUpdatePresence3D'] = jest.fn(); @@ -276,7 +265,7 @@ describe('Presence3DManager', () => { id: '123', }); - expect(presence3DManager['room'].presence.update).not.toBeCalled(); + expect(presence3DManager['room'].presence.update).not.toHaveBeenCalledTimes(2); }); test('should not update presence if participant is not local', () => { @@ -289,7 +278,7 @@ describe('Presence3DManager', () => { id: '123', }); - expect(presence3DManager['room'].presence.update).not.toBeCalled(); + expect(presence3DManager['room'].presence.update).not.toHaveBeenCalledTimes(2); }); test('should update presence if participant is local', () => { @@ -304,7 +293,9 @@ describe('Presence3DManager', () => { presence3DManager['unthrottledUpdatePresence3D'](modifiedLocalParticipant); - expect(presence3DManager['room'].presence.update).toBeCalledWith(modifiedLocalParticipant); + expect(presence3DManager['room'].presence.update).toHaveBeenCalledWith( + modifiedLocalParticipant, + ); }); }); diff --git a/src/services/presence-3d-manager/index.ts b/src/services/presence-3d-manager/index.ts index 10b83229..7a214aa2 100644 --- a/src/services/presence-3d-manager/index.ts +++ b/src/services/presence-3d-manager/index.ts @@ -27,16 +27,20 @@ export class Presence3DManager { const { localParticipant } = this.useStore(StoreType.GLOBAL); // have to set manually because useStore is binded to the 3d plugin that creates the service - localParticipant.subscribe((participant) => { - if (this.localParticipant) { - if ( - this.localParticipant.name !== participant.name || - this.localParticipant.avatar?.model3DUrl !== participant.avatar?.model3DUrl || - this.localParticipant.slot !== participant.slot - ) { - this.unthrottledUpdatePresence3D({ ...participant }); - } - } + localParticipant.subscribe((data) => { + this.room.presence.update(data); + + const { participants } = this.useStore(StoreType.PRESENCE_3D); + + const participant = { + ...participants.value.find((participant) => participant.id === data.id), + ...data, + }; + + participants.publish([ + ...participants.value.filter((participant) => participant.id !== data.id), + participant, + ]); this.localParticipant = participant; }); @@ -118,9 +122,7 @@ export class Presence3DManager { }; private unthrottledUpdatePresence3D = (data: Participant): void => { - if (!data || !data.id) { - return; - } + if (!data?.id) return; const { participants, hasJoined3D } = this.useStore(StoreType.PRESENCE_3D);