From afee9eaa265f6292a1ac9f15505dd8e8f14a96fd Mon Sep 17 00:00:00 2001 From: Timo <16718859+toger5@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:14:29 +0200 Subject: [PATCH] Don't update mute when reaching the user count threshold. (#2474) * Dont update mute during call. --- src/room/GroupCallView.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index dfc4ff19..a88d1126 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -80,17 +80,12 @@ 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); + // This should use `useEffectEvent` (only available in experimental versions) useEffect(() => { - if (autoMuteHappened.current) return; - if (memberships.length >= MUTE_PARTICIPANT_COUNT) { + 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(() => { window.rtcSession = rtcSession;