Skip to content

Commit

Permalink
Merge pull request #3046 from element-hq/robin/close-action-patch
Browse files Browse the repository at this point in the history
Patch for v0.7: Send a 'close' action when the widget is ready to close
  • Loading branch information
robintown authored Mar 4, 2025
2 parents cf17426 + 05c079e commit ac9e7d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/rtcSessionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,20 @@ const widgetPostHangupProcedure = async (
// 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.
await widget.api.transport.send(ElementWidgetActions.HangupCall, {});
try {
await widget.api.transport.send(ElementWidgetActions.HangupCall, {});
} catch (e) {
logger.error("Failed to send hangup action", e);
}
// To make the hangup procedure behave more similarly to what future versions
// of Element Call will do, we additionally send a close action (even though
// we're not yet employing the distinction between 'hangup' and 'close' to
// display error screens)
try {
await widget.api.transport.send(ElementWidgetActions.Close, {});
} catch (e) {
logger.error("Failed to send close action", e);
}
};

export async function leaveRTCSession(
Expand Down
3 changes: 2 additions & 1 deletion src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import { getUrlParams } from "./UrlParams";
import { Config } from "./config/Config";
import { ElementCallReactionEventType } from "./reactions";

// Subset of the actions in matrix-react-sdk
// Subset of the actions in element-web
export enum ElementWidgetActions {
JoinCall = "io.element.join",
HangupCall = "im.vector.hangup",
Close = "io.element.close",
TileLayout = "io.element.tile_layout",
SpotlightLayout = "io.element.spotlight_layout",
// This can be sent as from or to widget
Expand Down

0 comments on commit ac9e7d2

Please sign in to comment.