From df0e138229afc94e8f491e3a2b9126ed849645d7 Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 10 Jul 2024 09:58:24 +0200 Subject: [PATCH] Dont update mute during call. --- src/room/GroupCallView.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index dfc4ff19..965b706f 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -80,17 +80,14 @@ export const GroupCallView: FC = ({ const memberships = useMatrixRTCSessionMemberships(rtcSession); const isJoined = useMatrixRTCSessionJoinState(rtcSession); - // The mute state reactively gets updated once the participant count reaches the threshold. - // The user then still is able to unmute again. - // The more common case is that the user is muted from the start (participant count is already over the threshold). - const autoMuteHappened = useRef(false); - useEffect(() => { - if (autoMuteHappened.current) return; - if (memberships.length >= MUTE_PARTICIPANT_COUNT) { + // this should be useEffectEvent (only available in experimental versions) + const participantMuteOnce = useCallback(() => { + if (memberships.length >= MUTE_PARTICIPANT_COUNT) muteStates.audio.setEnabled?.(false); - autoMuteHappened.current = true; - } - }, [autoMuteHappened, memberships, muteStates.audio]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + useEffect(() => participantMuteOnce(), [participantMuteOnce]); useEffect(() => { window.rtcSession = rtcSession;