From 5c580bed14abef06a7b034cc8166d2c61ed579e4 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Mon, 16 Dec 2024 15:41:49 +0000 Subject: [PATCH] fix a couple of bugs --- src/reactions/useReactionsReader.ts | 2 +- src/room/InCallView.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/reactions/useReactionsReader.ts b/src/reactions/useReactionsReader.ts index cfffe5ec..0363edf6 100644 --- a/src/reactions/useReactionsReader.ts +++ b/src/reactions/useReactionsReader.ts @@ -245,7 +245,7 @@ export default function useReactionsReader(rtcSession: MatrixRTCSession): { } } else if (event.getType() === EventType.RoomRedaction) { const targetEvent = event.event.redacts; - const targetUser = Object.entries(latestRaisedHands.current).find( + const targetUser = Object.entries(latestRaisedHands.current.value).find( ([_u, r]) => r.reactionEventId === targetEvent, )?.[0]; if (!targetUser) { diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 73e8e1b1..f0e1d449 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -96,6 +96,7 @@ import { useSetting, } from "../settings/settings"; import useReactionsReader from "../reactions/useReactionsReader"; +import { useLatest } from "../useLatest"; const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); @@ -129,17 +130,18 @@ export const ActiveCall: FC = (props) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const reader = useReactionsReader(props.rtcSession); + const reader = useLatest(useReactionsReader(props.rtcSession)); useEffect(() => { if (livekitRoom !== undefined && reader !== undefined) { + console.log("Creating new VM"); const vm = new CallViewModel( props.rtcSession, livekitRoom, props.e2eeSystem, connStateObservable, - reader.raisedHands, - reader.reactions, + reader.current.raisedHands, + reader.current.reactions, ); setVm(vm); return (): void => vm.destroy();