Skip to content

Commit 2b92bf3

Browse files
committed
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 matrix-org/matrix-js-sdk#2502
1 parent 4dcec50 commit 2b92bf3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/room/usePTT.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const usePTT = (
130130
const onMuteStateChanged = useCallback(() => {
131131
const activeSpeakerFeed = getActiveSpeakerFeed(userMediaFeeds, groupCall);
132132

133-
let blocked = false;
133+
let blocked = transmitBlocked;
134134
if (activeSpeakerUserId === null && activeSpeakerFeed !== null) {
135135
if (activeSpeakerFeed.userId === client.getUserId()) {
136136
playClip(PTTClipID.START_TALKING_LOCAL);
@@ -141,8 +141,8 @@ export const usePTT = (
141141
playClip(PTTClipID.END_TALKING);
142142
} else if (
143143
pttButtonHeld &&
144-
activeSpeakerUserId === client.getUserId() &&
145-
activeSpeakerFeed?.userId !== client.getUserId()
144+
activeSpeakerFeed?.userId !== client.getUserId() &&
145+
!transmitBlocked
146146
) {
147147
// We were talking but we've been cut off: mute our own mic
148148
// (this is the easier way of cutting other speakers off if an
@@ -167,6 +167,7 @@ export const usePTT = (
167167
client,
168168
userMediaFeeds,
169169
setMicMuteWrapper,
170+
transmitBlocked,
170171
]);
171172

172173
useEffect(() => {

0 commit comments

Comments
 (0)