Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
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

View file

@ -102,6 +102,14 @@ let widgetApi: WidgetApi | undefined;
let meetApi: _JitsiMeetExternalAPI | undefined; let meetApi: _JitsiMeetExternalAPI | undefined;
let skipOurWelcomeScreen = false; 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> => { const setupCompleted = (async (): Promise<string | void> => {
try { try {
// Queue a config.json lookup asap, so we can use it later on. We want this to be concurrent with // 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) => { handleAction(ElementWidgetActions.DeviceMute, async (params) => {
if (!meetApi) return; if (!meetApi) return;
const [audioEnabled, videoEnabled] = ( const [audioEnabled, videoEnabled] = await checkAudioVideoEnabled();
await Promise.all([meetApi.isAudioMuted(), meetApi.isVideoMuted()])
).map((muted) => !muted);
if (Object.keys(params).length === 0) { if (Object.keys(params).length === 0) {
// Handle query // Handle query
@ -526,9 +532,10 @@ const onErrorOccurred = ({ error }: Parameters<ExternalAPIEventCallbacks["errorO
const onMuteStatusChanged = async (): Promise<void> => { const onMuteStatusChanged = async (): Promise<void> => {
if (!meetApi) return; if (!meetApi) return;
const [audioEnabled, videoEnabled] = await checkAudioVideoEnabled();
void widgetApi?.transport.send(ElementWidgetActions.DeviceMute, { void widgetApi?.transport.send(ElementWidgetActions.DeviceMute, {
audio_enabled: !(await meetApi.isAudioMuted()), audio_enabled: audioEnabled,
video_enabled: !(await meetApi.isVideoMuted()), video_enabled: videoEnabled,
}); });
}; };