You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
Implement widget API for signaling the widget to gracefully terminate
In theory, widgets could use iframe unload/beforeunload events for cleanup, but in practice browsers have restrictions on what can be done in those events which may not give sufficient time for clean termination. Signed-off-by: Pauli Virtanen <pav@iki.fi>
This commit is contained in:
@@ -87,6 +87,19 @@ export default class WidgetMessaging {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the widget that it should terminate now.
|
||||
* It is not necessarily called in all instances before the widget is removed,
|
||||
* and the client may force termination with a timeout.
|
||||
* @returns {Promise<*>} Resolves when widget has acknowledged the message.
|
||||
*/
|
||||
terminate() {
|
||||
return this.messageToWidget({
|
||||
api: OUTBOUND_API_NAME,
|
||||
action: KnownWidgetActions.Terminate,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a screenshot from a widget
|
||||
* @return {Promise} To be resolved with screenshot data when it has been generated
|
||||
|
||||
Reference in New Issue
Block a user