Skip to content

Commit

Permalink
add sendContentLoaded option to widgetClient
Browse files Browse the repository at this point in the history
Signed-off-by: Timo K <[email protected]>
  • Loading branch information
toger5 committed Feb 29, 2024
1 parent 8123e9a commit 82bd422
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<void> {
Expand Down
3 changes: 2 additions & 1 deletion src/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 82bd422

Please sign in to comment.