Skip to content

Commit b5336c9

Browse files
authored
Fix camera getting muted when disconnecting from a video room (#21958)
1 parent 2c7680b commit b5336c9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/vector/jitsi/index.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,14 @@ function joinConference(audioDevice?: string, videoDevice?: string) {
378378
if (isVideoChannel) meetApi.executeCommand("setTileView", true);
379379
});
380380

381-
meetApi.on("readyToClose", () => {
382-
switchVisibleContainers();
381+
meetApi.on("videoConferenceLeft", () => {
383382
notifyHangup();
383+
meetApi = null;
384+
});
384385

386+
meetApi.on("readyToClose", () => {
387+
switchVisibleContainers();
385388
document.getElementById("jitsiContainer").innerHTML = "";
386-
meetApi = null;
387389

388390
if (skipOurWelcomeScreen) {
389391
skipToJitsiSplashScreen();
@@ -404,8 +406,17 @@ function joinConference(audioDevice?: string, videoDevice?: string) {
404406
});
405407

406408
meetApi.on("videoMuteStatusChanged", ({ muted }) => {
407-
const action = muted ? ElementWidgetActions.MuteVideo : ElementWidgetActions.UnmuteVideo;
408-
widgetApi.transport.send(action, {});
409+
if (muted) {
410+
// Jitsi Meet always sends a "video muted" event directly before
411+
// hanging up, which we need to ignore by padding the timeout here,
412+
// otherwise the React SDK will mistakenly think the user turned off
413+
// their video by hand
414+
setTimeout(() => {
415+
if (meetApi) widgetApi.transport.send(ElementWidgetActions.MuteVideo, {});
416+
}, 200);
417+
} else {
418+
widgetApi.transport.send(ElementWidgetActions.UnmuteVideo, {});
419+
}
409420
});
410421

411422
["videoConferenceJoined", "participantJoined", "participantLeft"].forEach(event => {

0 commit comments

Comments
 (0)