diff --git a/src/room/CallEventAudioRenderer.test.tsx b/src/room/CallEventAudioRenderer.test.tsx index 5bb1ba19..2be2d186 100644 --- a/src/room/CallEventAudioRenderer.test.tsx +++ b/src/room/CallEventAudioRenderer.test.tsx @@ -199,3 +199,43 @@ test("plays no sound when the participant list is more than the maximum size", ( }); expect(playSound).toBeCalledWith("left"); }); + +test("plays one sound when a hand is raised", () => { + const { session, vm } = getMockEnv([local, alice]); + render(); + // Joining a call usually means remote participants are added later. + act(() => { + vm.updateReactions({ + raisedHands: { + [bobRtcMember.callId]: new Date(), + }, + reactions: {}, + }); + }); + expect(playSound).toBeCalledWith("raiseHand"); +}); + +test("should not play a sound when a hand raise is retracted", () => { + const { session, vm } = getMockEnv([local, alice]); + render(); + // Joining a call usually means remote participants are added later. + act(() => { + vm.updateReactions({ + raisedHands: { + ["foo"]: new Date(), + ["bar"]: new Date(), + }, + reactions: {}, + }); + }); + expect(playSound).toHaveBeenCalledTimes(2); + act(() => { + vm.updateReactions({ + raisedHands: { + ["foo"]: new Date(), + }, + reactions: {}, + }); + }); + expect(playSound).toHaveBeenCalledTimes(2); +}); diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index 61251600..06fb14bd 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -81,7 +81,6 @@ import { oneOnOneLayout } from "./OneOnOneLayout"; import { pipLayout } from "./PipLayout"; import { EncryptionSystem } from "../e2ee/sharedKeyManagement"; import { observeSpeaker } from "./observeSpeaker"; -import { useReactions } from "../useReactions"; import { ReactionOption } from "../reactions"; // How long we wait after a focus switch before showing the real participant @@ -1122,10 +1121,13 @@ export class CallViewModel extends ViewModel { Record >(); - public readonly handRaised = this.handsRaisedSubject.asObservable(); + public readonly handsRaised = this.handsRaisedSubject.asObservable(); public readonly reactions = this.reactionsSubject.asObservable(); - public updateReactions(data: ReturnType): void { + public updateReactions(data: { + raisedHands: Record; + reactions: Record; + }): void { this.handsRaisedSubject.next(data.raisedHands); this.reactionsSubject.next(data.reactions); }