Skip to content

Commit

Permalink
Reduce video rooms log spam (#22665)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
robintown authored Jun 27, 2022
1 parent 5f176fa commit feccdec
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/vector/jitsi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ const ack = (ev: CustomEvent<IWidgetApiRequest>) => widgetApi.transport.reply(ev
new Promise<void>(resolve => {
widgetApi.once(`action:${ElementWidgetActions.ClientReady}`, ev => {
ev.preventDefault();
widgetApi.transport.reply(ev.detail, {});
resolve();
widgetApi.transport.reply(ev.detail, {});
});
}),
new Promise<void>(resolve => {
Expand Down Expand Up @@ -145,19 +145,22 @@ const ack = (ev: CustomEvent<IWidgetApiRequest>) => widgetApi.transport.reply(ev

widgetApi.on(`action:${ElementWidgetActions.JoinCall}`,
(ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
const { audioDevice, videoDevice } = ev.detail.data;
joinConference(audioDevice as string | null, videoDevice as string | null);
ack(ev);
},
);
widgetApi.on(`action:${ElementWidgetActions.HangupCall}`,
(ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
meetApi?.executeCommand('hangup');
ack(ev);
},
);
widgetApi.on(`action:${ElementWidgetActions.ForceHangupCall}`,
(ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
meetApi?.dispose();
notifyHangup();
meetApi = null;
Expand All @@ -167,38 +170,43 @@ const ack = (ev: CustomEvent<IWidgetApiRequest>) => widgetApi.transport.reply(ev
);
widgetApi.on(`action:${ElementWidgetActions.MuteAudio}`,
async (ev: CustomEvent<IWidgetApiRequest>) => {
ack(ev);
ev.preventDefault();
if (meetApi && !await meetApi.isAudioMuted()) {
meetApi.executeCommand('toggleAudio');
}
ack(ev);
},
);
widgetApi.on(`action:${ElementWidgetActions.UnmuteAudio}`,
async (ev: CustomEvent<IWidgetApiRequest>) => {
ack(ev);
ev.preventDefault();
if (meetApi && await meetApi.isAudioMuted()) {
meetApi.executeCommand('toggleAudio');
}
ack(ev);
},
);
widgetApi.on(`action:${ElementWidgetActions.MuteVideo}`,
async (ev: CustomEvent<IWidgetApiRequest>) => {
ack(ev);
ev.preventDefault();
if (meetApi && !await meetApi.isVideoMuted()) {
meetApi.executeCommand('toggleVideo');
}
ack(ev);
},
);
widgetApi.on(`action:${ElementWidgetActions.UnmuteVideo}`,
async (ev: CustomEvent<IWidgetApiRequest>) => {
ack(ev);
ev.preventDefault();
if (meetApi && await meetApi.isVideoMuted()) {
meetApi.executeCommand('toggleVideo');
}
ack(ev);
},
);
widgetApi.on(`action:${ElementWidgetActions.StartLiveStream}`,
(ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
if (meetApi) {
meetApi.executeCommand('startRecording', {
mode: 'stream',
Expand Down

0 comments on commit feccdec

Please sign in to comment.