Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Reduce video rooms log spam #8913

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/stores/VideoChannelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {
messaging,
`action:${ElementWidgetActions.JoinCall}`,
(ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
this.ack(ev);
return true;
},
Expand Down Expand Up @@ -281,42 +282,49 @@ export default class VideoChannelStore extends AsyncStoreWithClient<null> {
await removeOurDevice(room);
};

private ack = (ev: CustomEvent<IWidgetApiRequest>) => {
private ack = (ev: CustomEvent<IWidgetApiRequest>, messaging = this.activeChannel) => {
// Even if we don't have a reply to a given widget action, we still need
// to give the widget API something to acknowledge receipt
this.activeChannel.transport.reply(ev.detail, {});
messaging.transport.reply(ev.detail, {});
};

private onHangup = async (ev: CustomEvent<IWidgetApiRequest>) => {
this.ack(ev);
ev.preventDefault();
const messaging = this.activeChannel;
// In case this hangup is caused by Jitsi Meet crashing at startup,
// wait for the connection event in order to avoid racing
if (!this.connected) await waitForEvent(this, VideoChannelEvent.Connect);
await this.setDisconnected();
this.ack(ev, messaging);
};

private onParticipants = (ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
this.participants = ev.detail.data.participants as IJitsiParticipant[];
this.emit(VideoChannelEvent.Participants, this.roomId, ev.detail.data.participants);
this.ack(ev);
};

private onMuteAudio = (ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
this.audioMuted = true;
this.ack(ev);
};

private onUnmuteAudio = (ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
this.audioMuted = false;
this.ack(ev);
};

private onMuteVideo = (ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
this.videoMuted = true;
this.ack(ev);
};

private onUnmuteVideo = (ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
this.videoMuted = false;
this.ack(ev);
};
Expand Down
2 changes: 2 additions & 0 deletions src/stores/widgets/StopGapWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export class StopGapWidget extends EventEmitter {
if (WidgetType.JITSI.matches(this.mockWidget.type)) {
this.messaging.on(`action:${ElementWidgetActions.HangupCall}`,
(ev: CustomEvent<IHangupCallApiRequest>) => {
ev.preventDefault();
if (ev.detail.data?.errorMessage) {
Modal.createDialog(ErrorDialog, {
title: _t("Connection lost"),
Expand All @@ -382,6 +383,7 @@ export class StopGapWidget extends EventEmitter {
}),
});
}
this.messaging.transport.reply(ev.detail, <IWidgetApiRequestEmptyData>{});
},
);
}
Expand Down
4 changes: 2 additions & 2 deletions test/stores/VideoChannelStore-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe("VideoChannelStore", () => {
const waitForConnect = new Promise<void>(resolve =>
store.once(VideoChannelEvent.Connect, resolve),
);
join({ detail: {} } as unknown as CustomEvent<IWidgetApiRequest>);
join(new CustomEvent("widgetapirequest", { detail: {} }) as CustomEvent<IWidgetApiRequest>);
await waitForConnect;
};

Expand All @@ -109,7 +109,7 @@ describe("VideoChannelStore", () => {
const waitForHangup = new Promise<void>(resolve =>
store.once(VideoChannelEvent.Disconnect, resolve),
);
hangup({ detail: {} } as unknown as CustomEvent<IWidgetApiRequest>);
hangup(new CustomEvent("widgetapirequest", { detail: {} }) as CustomEvent<IWidgetApiRequest>);
await waitForHangup;
};

Expand Down