From 81c7f8df2b84f7cc00047d7748fc7575663df090 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Jul 2023 08:59:00 +0100 Subject: [PATCH 1/2] Clear requiresClient and show pop-out if widget-api fails to ready --- src/components/views/elements/AppTile.tsx | 8 +++++--- src/stores/widgets/StopGapWidget.ts | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/AppTile.tsx b/src/components/views/elements/AppTile.tsx index 2c1125e56d3..40770297403 100644 --- a/src/components/views/elements/AppTile.tsx +++ b/src/components/views/elements/AppTile.tsx @@ -345,14 +345,16 @@ export default class AppTile extends React.Component { private setupSgListeners(): void { this.sgWidget?.on("preparing", this.onWidgetPreparing); + this.sgWidget?.on("error:preparing", this.updateRequiresClient); // emits when the capabilities have been set up or changed - this.sgWidget?.on("capabilitiesNotified", this.onWidgetCapabilitiesNotified); + this.sgWidget?.on("capabilitiesNotified", this.updateRequiresClient); } private stopSgListeners(): void { if (!this.sgWidget) return; this.sgWidget.off("preparing", this.onWidgetPreparing); - this.sgWidget.off("capabilitiesNotified", this.onWidgetCapabilitiesNotified); + this.sgWidget.off("error:preparing", this.updateRequiresClient); + this.sgWidget.off("capabilitiesNotified", this.updateRequiresClient); } private resetWidget(newProps: IProps): void { @@ -441,7 +443,7 @@ export default class AppTile extends React.Component { this.setState({ loading: false }); }; - private onWidgetCapabilitiesNotified = (): void => { + private updateRequiresClient = (): void => { this.setState({ requiresClient: !!this.sgWidget?.widgetApi?.hasCapability(ElementWidgetCapabilities.RequiresClient), }); diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index 2781612a0c3..42cf56f95a7 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -285,6 +285,7 @@ export class StopGapWidget extends EventEmitter { this.messaging = new ClientWidgetApi(this.mockWidget, iframe, driver); this.messaging.on("preparing", () => this.emit("preparing")); + this.messaging.on("error:preparing", (err: unknown) => this.emit("error:preparing", err)); this.messaging.on("ready", () => { WidgetMessagingStore.instance.storeMessaging(this.mockWidget, this.roomId, this.messaging!); this.emit("ready"); From a1483a0e13b30bdf6f11cda4fddf666a93223846 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Jul 2023 11:23:16 +0100 Subject: [PATCH 2/2] Upgrade matrix-widget-api --- package.json | 2 +- yarn.lock | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 34cc53e9843..0f62718bac7 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "matrix-encrypt-attachment": "^1.0.3", "matrix-events-sdk": "0.0.1", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", - "matrix-widget-api": "^1.4.0", + "matrix-widget-api": "^1.5.0", "memoize-one": "^6.0.0", "minimist": "^1.2.5", "oidc-client-ts": "^2.2.4", diff --git a/yarn.lock b/yarn.lock index 1820ee78b7e..2b3d167a309 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6900,7 +6900,7 @@ matrix-web-i18n@^1.4.0: "@babel/traverse" "^7.18.5" walk "^2.3.15" -matrix-widget-api@^1.3.1, matrix-widget-api@^1.4.0: +matrix-widget-api@^1.3.1: version "1.4.0" resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.4.0.tgz#e426ec16a013897f3a4a9c2bff423f54ab0ba745" integrity sha512-dw0dRylGQzDUoiaY/g5xx1tBbS7aoov31PRtFMAvG58/4uerYllV9Gfou7w+I1aglwB6hihTREzKltVjARWV6A== @@ -6908,6 +6908,14 @@ matrix-widget-api@^1.3.1, matrix-widget-api@^1.4.0: "@types/events" "^3.0.0" events "^3.2.0" +matrix-widget-api@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.5.0.tgz#4ae3e46a7f2854f944ddaf8a5af63d72fba76c45" + integrity sha512-hKGfqQKK5qVMwW0Sp8l2TiuW8UuHafTvUZNSWBPghedB/rSFbVLlr0mufuEV0iq/pQ7ChW96q/WEC6Llie4SnA== + dependencies: + "@types/events" "^3.0.0" + events "^3.2.0" + md5@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/md5/-/md5-2.3.0.tgz#c3da9a6aae3a30b46b7b0c349b87b110dc3bda4f"