From 82bd4222dd4cf2c1c5efc701037f10afcded81e2 Mon Sep 17 00:00:00 2001 From: Timo K Date: Wed, 28 Feb 2024 16:24:28 +0100 Subject: [PATCH] add sendContentLoaded option to widgetClient Signed-off-by: Timo K --- src/embedded.ts | 14 +++++++++++++- src/matrix.ts | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/embedded.ts b/src/embedded.ts index 178d74b2ec7..e1c3252e54c 100644 --- a/src/embedded.ts +++ b/src/embedded.ts @@ -108,11 +108,23 @@ export class RoomWidgetClient extends MatrixClient { private lifecycle?: AbortController; private syncState: SyncState | null = null; + /** + * + * @param widgetApi - the widget api to use for the embedded "fake" client + * @param capabilities - + * @param roomId - + * @param opts - Client related options + * @param sendContentLoaded - Whether to send a content loaded event. + * Set to false if: the widget uses waitForIFrameLoad=true, or if the + * the widget wants to send the ContentLoaded action at a later point in time + * after initial setup. + */ public constructor( private readonly widgetApi: WidgetApi, private readonly capabilities: ICapabilities, private readonly roomId: string, opts: IMatrixClientCreateOpts, + sendContentLoaded = true, ) { super(opts); @@ -165,7 +177,7 @@ export class RoomWidgetClient extends MatrixClient { // does *not* (yes, that is the right way around) wait for this event. Let's // start sending this, then once this has rolled out, we can change element-web to // use waitForIFrameLoad=false and have a widget API that's less racy. - widgetApi.sendContentLoaded(); + if (sendContentLoaded) widgetApi.sendContentLoaded(); } public async startClient(opts: IStartClientOpts = {}): Promise { diff --git a/src/matrix.ts b/src/matrix.ts index 9dd83affade..6b947729d8e 100644 --- a/src/matrix.ts +++ b/src/matrix.ts @@ -169,6 +169,7 @@ export function createRoomWidgetClient( capabilities: ICapabilities, roomId: string, opts: ICreateClientOpts, + sendContentLoaded = true, ): MatrixClient { - return new RoomWidgetClient(widgetApi, capabilities, roomId, amendClientOpts(opts)); + return new RoomWidgetClient(widgetApi, capabilities, roomId, amendClientOpts(opts), sendContentLoaded); }