@@ -102,6 +102,14 @@ let widgetApi: WidgetApi | undefined;
102
102
let meetApi : _JitsiMeetExternalAPI | undefined ;
103
103
let skipOurWelcomeScreen = false ;
104
104
105
+ async function checkAudioVideoEnabled ( ) : Promise < [ audioEnabled : boolean , videoEnabled : boolean ] > {
106
+ if ( ! meetApi ) return [ false , false ] ;
107
+ const [ audioEnabled , videoEnabled ] = ( await Promise . all ( [ meetApi . isAudioMuted ( ) , meetApi . isVideoMuted ( ) ] ) ) . map (
108
+ ( muted ) => ! muted ,
109
+ ) ;
110
+ return [ audioEnabled , videoEnabled ] ;
111
+ }
112
+
105
113
const setupCompleted = ( async ( ) : Promise < string | void > => {
106
114
try {
107
115
// Queue a config.json lookup asap, so we can use it later on. We want this to be concurrent with
@@ -195,9 +203,7 @@ const setupCompleted = (async (): Promise<string | void> => {
195
203
handleAction ( ElementWidgetActions . DeviceMute , async ( params ) => {
196
204
if ( ! meetApi ) return ;
197
205
198
- const [ audioEnabled , videoEnabled ] = (
199
- await Promise . all ( [ meetApi . isAudioMuted ( ) , meetApi . isVideoMuted ( ) ] )
200
- ) . map ( ( muted ) => ! muted ) ;
206
+ const [ audioEnabled , videoEnabled ] = await checkAudioVideoEnabled ( ) ;
201
207
202
208
if ( Object . keys ( params ) . length === 0 ) {
203
209
// Handle query
@@ -526,9 +532,10 @@ const onErrorOccurred = ({ error }: Parameters<ExternalAPIEventCallbacks["errorO
526
532
527
533
const onMuteStatusChanged = async ( ) : Promise < void > => {
528
534
if ( ! meetApi ) return ;
535
+ const [ audioEnabled , videoEnabled ] = await checkAudioVideoEnabled ( ) ;
529
536
void widgetApi ?. transport . send ( ElementWidgetActions . DeviceMute , {
530
- audio_enabled : ! ( await meetApi . isAudioMuted ( ) ) ,
531
- video_enabled : ! ( await meetApi . isVideoMuted ( ) ) ,
537
+ audio_enabled : audioEnabled ,
538
+ video_enabled : videoEnabled ,
532
539
} ) ;
533
540
} ;
534
541
0 commit comments