From feccdec581cfb0754f37b0bb1393374689aeee65 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 27 Jun 2022 15:30:56 -0400 Subject: [PATCH] Reduce video rooms log spam (#22665) If you forget to call preventDefault in widget action handlers, matrix-widget-api logs a bunch of errors complaining that the action is unsupported/unhandled, even if it isn't. --- src/vector/jitsi/index.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index 8cf7002e6..b055abbf1 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -98,8 +98,8 @@ const ack = (ev: CustomEvent) => widgetApi.transport.reply(ev new Promise(resolve => { widgetApi.once(`action:${ElementWidgetActions.ClientReady}`, ev => { ev.preventDefault(); - widgetApi.transport.reply(ev.detail, {}); resolve(); + widgetApi.transport.reply(ev.detail, {}); }); }), new Promise(resolve => { @@ -145,6 +145,7 @@ const ack = (ev: CustomEvent) => widgetApi.transport.reply(ev widgetApi.on(`action:${ElementWidgetActions.JoinCall}`, (ev: CustomEvent) => { + ev.preventDefault(); const { audioDevice, videoDevice } = ev.detail.data; joinConference(audioDevice as string | null, videoDevice as string | null); ack(ev); @@ -152,12 +153,14 @@ const ack = (ev: CustomEvent) => widgetApi.transport.reply(ev ); widgetApi.on(`action:${ElementWidgetActions.HangupCall}`, (ev: CustomEvent) => { + ev.preventDefault(); meetApi?.executeCommand('hangup'); ack(ev); }, ); widgetApi.on(`action:${ElementWidgetActions.ForceHangupCall}`, (ev: CustomEvent) => { + ev.preventDefault(); meetApi?.dispose(); notifyHangup(); meetApi = null; @@ -167,38 +170,43 @@ const ack = (ev: CustomEvent) => widgetApi.transport.reply(ev ); widgetApi.on(`action:${ElementWidgetActions.MuteAudio}`, async (ev: CustomEvent) => { - ack(ev); + ev.preventDefault(); if (meetApi && !await meetApi.isAudioMuted()) { meetApi.executeCommand('toggleAudio'); } + ack(ev); }, ); widgetApi.on(`action:${ElementWidgetActions.UnmuteAudio}`, async (ev: CustomEvent) => { - ack(ev); + ev.preventDefault(); if (meetApi && await meetApi.isAudioMuted()) { meetApi.executeCommand('toggleAudio'); } + ack(ev); }, ); widgetApi.on(`action:${ElementWidgetActions.MuteVideo}`, async (ev: CustomEvent) => { - ack(ev); + ev.preventDefault(); if (meetApi && !await meetApi.isVideoMuted()) { meetApi.executeCommand('toggleVideo'); } + ack(ev); }, ); widgetApi.on(`action:${ElementWidgetActions.UnmuteVideo}`, async (ev: CustomEvent) => { - ack(ev); + ev.preventDefault(); if (meetApi && await meetApi.isVideoMuted()) { meetApi.executeCommand('toggleVideo'); } + ack(ev); }, ); widgetApi.on(`action:${ElementWidgetActions.StartLiveStream}`, (ev: CustomEvent) => { + ev.preventDefault(); if (meetApi) { meetApi.executeCommand('startRecording', { mode: 'stream',