Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/27858/head
Michael Telatynski 2024-07-25 20:10:11 +01:00
parent 5a1b38cd74
commit 88ddf05930
No known key found for this signature in database
GPG Key ID: A2B008A5F49F5D0D
1 changed files with 12 additions and 5 deletions

View File

@ -102,6 +102,14 @@ let widgetApi: WidgetApi | undefined;
let meetApi: _JitsiMeetExternalAPI | undefined;
let skipOurWelcomeScreen = false;
async function checkAudioVideoEnabled(): Promise<[audioEnabled: boolean, videoEnabled: boolean]> {
if (!meetApi) return [false, false];
const [audioEnabled, videoEnabled] = (await Promise.all([meetApi.isAudioMuted(), meetApi.isVideoMuted()])).map(
(muted) => !muted,
);
return [audioEnabled, videoEnabled];
}
const setupCompleted = (async (): Promise<string | void> => {
try {
// 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> => {
handleAction(ElementWidgetActions.DeviceMute, async (params) => {
if (!meetApi) return;
const [audioEnabled, videoEnabled] = (
await Promise.all([meetApi.isAudioMuted(), meetApi.isVideoMuted()])
).map((muted) => !muted);
const [audioEnabled, videoEnabled] = await checkAudioVideoEnabled();
if (Object.keys(params).length === 0) {
// Handle query
@ -526,9 +532,10 @@ const onErrorOccurred = ({ error }: Parameters<ExternalAPIEventCallbacks["errorO
const onMuteStatusChanged = async (): Promise<void> => {
if (!meetApi) return;
const [audioEnabled, videoEnabled] = await checkAudioVideoEnabled();
void widgetApi?.transport.send(ElementWidgetActions.DeviceMute, {
audio_enabled: !(await meetApi.isAudioMuted()),
video_enabled: !(await meetApi.isVideoMuted()),
audio_enabled: audioEnabled,
video_enabled: videoEnabled,
});
};