From 2b92bf3694b161959ed11d926ac4b2ebeecdf96d Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 7 Jul 2022 19:42:15 +0100 Subject: [PATCH] Fix talking collision not colliding properly The code was only entering the blocked state if the user was speaking, which often won't be the case when another person starts speaking because we'll have pressed the button but not got the ack back from the server yet. Add the transmitblocked flag instead so we don't enter that state again if we've already decided we've been blocked. We were also starting with blocked = false and so resetting it when it shouldn't have been reset. Also requires https://github.com/matrix-org/matrix-js-sdk/pull/2502 --- src/room/usePTT.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/room/usePTT.ts b/src/room/usePTT.ts index 096e662d..847a1aa8 100644 --- a/src/room/usePTT.ts +++ b/src/room/usePTT.ts @@ -130,7 +130,7 @@ export const usePTT = ( const onMuteStateChanged = useCallback(() => { const activeSpeakerFeed = getActiveSpeakerFeed(userMediaFeeds, groupCall); - let blocked = false; + let blocked = transmitBlocked; if (activeSpeakerUserId === null && activeSpeakerFeed !== null) { if (activeSpeakerFeed.userId === client.getUserId()) { playClip(PTTClipID.START_TALKING_LOCAL); @@ -141,8 +141,8 @@ export const usePTT = ( playClip(PTTClipID.END_TALKING); } else if ( pttButtonHeld && - activeSpeakerUserId === client.getUserId() && - activeSpeakerFeed?.userId !== client.getUserId() + activeSpeakerFeed?.userId !== client.getUserId() && + !transmitBlocked ) { // We were talking but we've been cut off: mute our own mic // (this is the easier way of cutting other speakers off if an @@ -167,6 +167,7 @@ export const usePTT = ( client, userMediaFeeds, setMicMuteWrapper, + transmitBlocked, ]); useEffect(() => {