mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-02 19:49:23 +00:00
use the same leave procedure
on hangup widget action on hangup button pressed Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -201,6 +201,22 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
const [leaveError, setLeaveError] = useState<Error | undefined>(undefined);
|
const [leaveError, setLeaveError] = useState<Error | undefined>(undefined);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
const widgetPostHangupProcedure = async (): Promise<void> => {
|
||||||
|
if (!widget) {
|
||||||
|
logger.warn("called widgetPostHangupProcedure without a widget.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 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, {});
|
||||||
|
};
|
||||||
|
|
||||||
const onLeave = useCallback(
|
const onLeave = useCallback(
|
||||||
async (leaveError?: Error) => {
|
async (leaveError?: Error) => {
|
||||||
setLeaveError(leaveError);
|
setLeaveError(leaveError);
|
||||||
@@ -217,15 +233,7 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
|
|
||||||
await leaveRTCSession(rtcSession);
|
await leaveRTCSession(rtcSession);
|
||||||
if (widget) {
|
if (widget) {
|
||||||
// we need to wait until the callEnded event is tracked on posthog.
|
widgetPostHangupProcedure();
|
||||||
// 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 (
|
if (
|
||||||
@@ -244,9 +252,9 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
const onHangup = async (
|
const onHangup = async (
|
||||||
ev: CustomEvent<IWidgetApiRequest>,
|
ev: CustomEvent<IWidgetApiRequest>,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
await leaveRTCSession(rtcSession);
|
|
||||||
widget!.api.transport.reply(ev.detail, {});
|
widget!.api.transport.reply(ev.detail, {});
|
||||||
widget!.api.setAlwaysOnScreen(false);
|
await leaveRTCSession(rtcSession);
|
||||||
|
widgetPostHangupProcedure();
|
||||||
};
|
};
|
||||||
widget.lazyActions.once(ElementWidgetActions.HangupCall, onHangup);
|
widget.lazyActions.once(ElementWidgetActions.HangupCall, onHangup);
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user