@@ -378,12 +378,14 @@ function joinConference(audioDevice?: string, videoDevice?: string) {
378
378
if ( isVideoChannel ) meetApi . executeCommand ( "setTileView" , true ) ;
379
379
} ) ;
380
380
381
- meetApi . on ( "readyToClose" , ( ) => {
382
- switchVisibleContainers ( ) ;
381
+ meetApi . on ( "videoConferenceLeft" , ( ) => {
383
382
notifyHangup ( ) ;
383
+ meetApi = null ;
384
+ } ) ;
384
385
386
+ meetApi . on ( "readyToClose" , ( ) => {
387
+ switchVisibleContainers ( ) ;
385
388
document . getElementById ( "jitsiContainer" ) . innerHTML = "" ;
386
- meetApi = null ;
387
389
388
390
if ( skipOurWelcomeScreen ) {
389
391
skipToJitsiSplashScreen ( ) ;
@@ -404,8 +406,17 @@ function joinConference(audioDevice?: string, videoDevice?: string) {
404
406
} ) ;
405
407
406
408
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
+ }
409
420
} ) ;
410
421
411
422
[ "videoConferenceJoined" , "participantJoined" , "participantLeft" ] . forEach ( event => {
0 commit comments