Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Update widget tile if the url should change #12381

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/components/views/elements/AppTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ export default class AppTile extends React.Component<IProps, IState> {
this.sgWidget?.on("error:preparing", this.updateRequiresClient);
// emits when the capabilities have been set up or changed
this.sgWidget?.on("capabilitiesNotified", this.updateRequiresClient);
this.sgWidget?.on("urlChanged", this.updateWidgetUrl);
}

private stopSgListeners(): void {
Expand All @@ -374,6 +375,7 @@ export default class AppTile extends React.Component<IProps, IState> {
this.sgWidget?.off("ready", this.onWidgetReady);
this.sgWidget.off("error:preparing", this.updateRequiresClient);
this.sgWidget.off("capabilitiesNotified", this.updateRequiresClient);
this.sgWidget?.off("urlChanged", this.updateWidgetUrl);
}

private resetWidget(newProps: IProps): void {
Expand Down Expand Up @@ -479,6 +481,12 @@ export default class AppTile extends React.Component<IProps, IState> {
// A new action should be introduced and the widget driver should be called here, so it informs the widget. (or connect to this by itself)
};

private updateWidgetUrl = (): void => {
this.setState({
widgetUrl: this.sgWidget?.embedUrl,
});
};

private onAction = (payload: ActionPayload): void => {
switch (payload.action) {
case "m.sticker":
Expand Down
2 changes: 2 additions & 0 deletions src/stores/widgets/StopGapWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ export class StopGapWidget extends EventEmitter {
if (defaultManager && WidgetUtils.isScalarUrl(defaultManager.apiUrl)) {
const scalar = defaultManager.getScalarClient();
this.scalarToken = await scalar.getScalarToken();
// The URL will have changed as a result of this.
this.emit('urlChanged');
}
}
}
Expand Down
Loading