Skip to content

Commit 44f51fd

Browse files
authored
Clear requiresClient and show pop-out if widget-api fails to ready (matrix-org#11321)
* Clear requiresClient and show pop-out if widget-api fails to ready * Upgrade matrix-widget-api
1 parent 755f8d7 commit 44f51fd

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"matrix-encrypt-attachment": "^1.0.3",
100100
"matrix-events-sdk": "0.0.1",
101101
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",
102-
"matrix-widget-api": "^1.4.0",
102+
"matrix-widget-api": "^1.5.0",
103103
"memoize-one": "^6.0.0",
104104
"minimist": "^1.2.5",
105105
"oidc-client-ts": "^2.2.4",

src/components/views/elements/AppTile.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,16 @@ export default class AppTile extends React.Component<IProps, IState> {
346346

347347
private setupSgListeners(): void {
348348
this.sgWidget?.on("preparing", this.onWidgetPreparing);
349+
this.sgWidget?.on("error:preparing", this.updateRequiresClient);
349350
// emits when the capabilities have been set up or changed
350-
this.sgWidget?.on("capabilitiesNotified", this.onWidgetCapabilitiesNotified);
351+
this.sgWidget?.on("capabilitiesNotified", this.updateRequiresClient);
351352
}
352353

353354
private stopSgListeners(): void {
354355
if (!this.sgWidget) return;
355356
this.sgWidget.off("preparing", this.onWidgetPreparing);
356-
this.sgWidget.off("capabilitiesNotified", this.onWidgetCapabilitiesNotified);
357+
this.sgWidget.off("error:preparing", this.updateRequiresClient);
358+
this.sgWidget.off("capabilitiesNotified", this.updateRequiresClient);
357359
}
358360

359361
private resetWidget(newProps: IProps): void {
@@ -442,7 +444,7 @@ export default class AppTile extends React.Component<IProps, IState> {
442444
this.setState({ loading: false });
443445
};
444446

445-
private onWidgetCapabilitiesNotified = (): void => {
447+
private updateRequiresClient = (): void => {
446448
this.setState({
447449
requiresClient: !!this.sgWidget?.widgetApi?.hasCapability(ElementWidgetCapabilities.RequiresClient),
448450
});

src/stores/widgets/StopGapWidget.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export class StopGapWidget extends EventEmitter {
285285

286286
this.messaging = new ClientWidgetApi(this.mockWidget, iframe, driver);
287287
this.messaging.on("preparing", () => this.emit("preparing"));
288+
this.messaging.on("error:preparing", (err: unknown) => this.emit("error:preparing", err));
288289
this.messaging.on("ready", () => {
289290
WidgetMessagingStore.instance.storeMessaging(this.mockWidget, this.roomId, this.messaging!);
290291
this.emit("ready");

yarn.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7019,14 +7019,6 @@ matrix-web-i18n@^1.4.0:
70197019
"@babel/traverse" "^7.18.5"
70207020
walk "^2.3.15"
70217021

7022-
matrix-widget-api@^1.4.0:
7023-
version "1.4.0"
7024-
resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.4.0.tgz#e426ec16a013897f3a4a9c2bff423f54ab0ba745"
7025-
integrity sha512-dw0dRylGQzDUoiaY/g5xx1tBbS7aoov31PRtFMAvG58/4uerYllV9Gfou7w+I1aglwB6hihTREzKltVjARWV6A==
7026-
dependencies:
7027-
"@types/events" "^3.0.0"
7028-
events "^3.2.0"
7029-
70307022
matrix-widget-api@^1.5.0:
70317023
version "1.5.0"
70327024
resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.5.0.tgz#4ae3e46a7f2854f944ddaf8a5af63d72fba76c45"

0 commit comments

Comments
 (0)