From aa33442983d46b822c266d6f4b31383ba5029f31 Mon Sep 17 00:00:00 2001 From: Robin Kouwenhoven <33722212+rkouwenhoven@users.noreply.github.com> Date: Thu, 14 Apr 2022 23:25:53 +0200 Subject: [PATCH] Move RequiresClient from MatrixCapabilities to ElementWidgetCapabilities (#8290) * Move RequiresClient from MatrixCapabilities to ElementWidgetCapabilities Signed-off-by: Robin Kouwenhoven * Replace usages of RequiresClient with new location Signed-off-by: Robin Kouwenhoven Co-authored-by: Travis Ralston --- src/components/views/elements/AppTile.tsx | 3 ++- src/stores/widgets/ElementWidgetCapabilities.ts | 5 +++++ src/stores/widgets/StopGapWidgetDriver.ts | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/views/elements/AppTile.tsx b/src/components/views/elements/AppTile.tsx index 840acd456a..e9e8c9474a 100644 --- a/src/components/views/elements/AppTile.tsx +++ b/src/components/views/elements/AppTile.tsx @@ -49,6 +49,7 @@ import WidgetUtils from '../../../utils/WidgetUtils'; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import { ActionPayload } from "../../../dispatcher/payloads"; import { Action } from '../../../dispatcher/actions'; +import { ElementWidgetCapabilities } from '../../../stores/widgets/ElementWidgetCapabilities'; interface IProps { app: IApp; @@ -430,7 +431,7 @@ export default class AppTile extends React.Component { private onWidgetCapabilitiesNotified = (): void => { this.setState({ - requiresClient: this.sgWidget.widgetApi.hasCapability(MatrixCapabilities.RequiresClient), + requiresClient: this.sgWidget.widgetApi.hasCapability(ElementWidgetCapabilities.RequiresClient), }); }; diff --git a/src/stores/widgets/ElementWidgetCapabilities.ts b/src/stores/widgets/ElementWidgetCapabilities.ts index e493d5618f..fd6653294c 100644 --- a/src/stores/widgets/ElementWidgetCapabilities.ts +++ b/src/stores/widgets/ElementWidgetCapabilities.ts @@ -19,4 +19,9 @@ export enum ElementWidgetCapabilities { * @deprecated Use MSC2931 instead. */ CanChangeViewedRoom = "io.element.view_room", + /** + * Ask Element to not give the option to move the widget into a separate tab. + * This replaces RequiresClient in MatrixCapabilities. + */ + RequiresClient = "io.element.requires_client", } diff --git a/src/stores/widgets/StopGapWidgetDriver.ts b/src/stores/widgets/StopGapWidgetDriver.ts index c33bbe06cf..6591a2c793 100644 --- a/src/stores/widgets/StopGapWidgetDriver.ts +++ b/src/stores/widgets/StopGapWidgetDriver.ts @@ -49,6 +49,7 @@ import dis from "../../dispatcher/dispatcher"; import { tryTransformPermalinkToLocalHref } from "../../utils/permalinks/Permalinks"; import SettingsStore from "../../settings/SettingsStore"; import { RoomViewStore } from "../RoomViewStore"; +import { ElementWidgetCapabilities } from "./ElementWidgetCapabilities"; // TODO: Purge this from the universe @@ -77,7 +78,7 @@ export class StopGapWidgetDriver extends WidgetDriver { // button if the widget says it supports screenshots. this.allowedCapabilities = new Set([...allowedCapabilities, MatrixCapabilities.Screenshots, - MatrixCapabilities.RequiresClient]); + ElementWidgetCapabilities.RequiresClient]); // Grant the permissions that are specific to given widget types if (WidgetType.JITSI.matches(this.forWidget.type) && forWidgetKind === WidgetKind.Room) {