Compare commits

...

4 Commits

Author SHA1 Message Date
Timo K
2d62027bfa update comment
Signed-off-by: Timo K <toger5@hotmail.de>
2023-10-30 17:18:36 +01:00
Timo K
b9b2a1b104 refactor widget hangup procedure
Signed-off-by: Timo K <toger5@hotmail.de>
2023-10-30 15:30:33 +01:00
Timo K
9c449c8de6 use the same leave procedure
on hangup widget action
on hangup button pressed

Signed-off-by: Timo K <toger5@hotmail.de>
2023-10-30 12:41:08 +01:00
Timo K
ee960e99df add await
Signed-off-by: Timo K <toger5@hotmail.de>
2023-10-30 12:18:02 +01:00
3 changed files with 21 additions and 15 deletions

View File

@@ -216,17 +216,6 @@ export const GroupCallView: FC<Props> = ({
);
await leaveRTCSession(rtcSession);
if (widget) {
// we need to wait until the callEnded event is tracked on posthog.
// Otherwise the iFrame gets killed before the callEnded event got tracked.
await new Promise((resolve) => window.setTimeout(resolve, 10)); // 10ms
widget.api.setAlwaysOnScreen(false);
PosthogAnalytics.instance.logout();
// we will always send the hangup event after the memberships have been updated
// calling leaveRTCSession.
widget.api.transport.send(ElementWidgetActions.HangupCall, {});
}
if (
!isPasswordlessUser &&
@@ -244,9 +233,8 @@ export const GroupCallView: FC<Props> = ({
const onHangup = async (
ev: CustomEvent<IWidgetApiRequest>,
): Promise<void> => {
leaveRTCSession(rtcSession);
widget!.api.transport.reply(ev.detail, {});
widget!.api.setAlwaysOnScreen(false);
await leaveRTCSession(rtcSession);
};
widget.lazyActions.once(ElementWidgetActions.HangupCall, onHangup);
return () => {

View File

@@ -19,6 +19,7 @@ import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
import { PosthogAnalytics } from "./analytics/PosthogAnalytics";
import { LivekitFocus } from "./livekit/LivekitFocus";
import { Config } from "./config/Config";
import { ElementWidgetActions, WidgetHelpers, widget } from "./widget";
function makeFocus(livekitAlias: string): LivekitFocus {
const urlFromConf = Config.get().livekit!.livekit_service_url;
@@ -47,9 +48,26 @@ export function enterRTCSession(rtcSession: MatrixRTCSession): void {
rtcSession.joinRoomSession([makeFocus(livekitAlias)]);
}
const widgetPostHangupProcedure = async (
widget: WidgetHelpers,
): Promise<void> => {
// we need to wait until the callEnded event is tracked on posthog.
// Otherwise the iFrame gets killed before the callEnded event got tracked.
await new Promise((resolve) => window.setTimeout(resolve, 10)); // 10ms
widget.api.setAlwaysOnScreen(false);
PosthogAnalytics.instance.logout();
// We send the hangup event after the memberships have been updated
// calling leaveRTCSession.
// We need to wait because this makes the client hosting this widget killing the IFrame.
widget.api.transport.send(ElementWidgetActions.HangupCall, {});
};
export async function leaveRTCSession(
rtcSession: MatrixRTCSession,
): Promise<void> {
//groupCallOTelMembership?.onLeaveCall();
await rtcSession.leaveRoomSession();
if (widget) {
await widgetPostHangupProcedure(widget);
}
}

View File

@@ -57,7 +57,7 @@ export interface ScreenshareStartData {
desktopCapturerSourceId: string;
}
interface WidgetHelpers {
export interface WidgetHelpers {
api: WidgetApi;
lazyActions: LazyEventEmitter;
client: Promise<MatrixClient>;