diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c0939871e2..4dad7a97f1 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -584,6 +584,7 @@ "Send stickers into this room": "Send stickers into this room", "Send stickers into your active room": "Send stickers into your active room", "Change which room you're viewing": "Change which room you're viewing", + "Change which room you're viewing and use permalinks": "Change which room you're viewing and use permalinks", "Change the topic of this room": "Change the topic of this room", "See when the topic changes in this room": "See when the topic changes in this room", "Change the topic of your active room": "Change the topic of your active room", diff --git a/src/stores/widgets/ElementWidgetActions.ts b/src/stores/widgets/ElementWidgetActions.ts index 76390086ab..de48746a74 100644 --- a/src/stores/widgets/ElementWidgetActions.ts +++ b/src/stores/widgets/ElementWidgetActions.ts @@ -20,9 +20,16 @@ export enum ElementWidgetActions { ClientReady = "im.vector.ready", HangupCall = "im.vector.hangup", OpenIntegrationManager = "integration_manager_open", + + /** + * @deprecated Use MSC2931 instead + */ ViewRoom = "io.element.view_room", } +/** + * @deprecated Use MSC2931 instead + */ export interface IViewRoomApiRequest extends IWidgetApiRequest { data: { room_id: string; // eslint-disable-line camelcase diff --git a/src/stores/widgets/ElementWidgetCapabilities.ts b/src/stores/widgets/ElementWidgetCapabilities.ts index 3f17d27909..e493d5618f 100644 --- a/src/stores/widgets/ElementWidgetCapabilities.ts +++ b/src/stores/widgets/ElementWidgetCapabilities.ts @@ -15,5 +15,8 @@ */ export enum ElementWidgetCapabilities { + /** + * @deprecated Use MSC2931 instead. + */ CanChangeViewedRoom = "io.element.view_room", } diff --git a/src/stores/widgets/StopGapWidgetDriver.ts b/src/stores/widgets/StopGapWidgetDriver.ts index 2d2d1fcbdb..8baea97fe0 100644 --- a/src/stores/widgets/StopGapWidgetDriver.ts +++ b/src/stores/widgets/StopGapWidgetDriver.ts @@ -43,6 +43,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event"; import { CHAT_EFFECTS } from "../../effects"; import { containsEmoji } from "../../effects/utils"; import dis from "../../dispatcher/dispatcher"; +import {tryTransformPermalinkToLocalHref} from "../../utils/permalinks/Permalinks"; // TODO: Purge this from the universe @@ -171,4 +172,12 @@ export class StopGapWidgetDriver extends WidgetDriver { }, }); } + + public async navigate(uri: string): Promise { + const localUri = tryTransformPermalinkToLocalHref(uri); + if (!localUri || localUri === uri) { // parse failure can lead to an unmodified URL + throw new Error("Failed to transform URI"); + } + window.location.hash = localUri; // it'll just be a fragment + } } diff --git a/src/widgets/CapabilityText.tsx b/src/widgets/CapabilityText.tsx index 834ea3ec37..044b7701ba 100644 --- a/src/widgets/CapabilityText.tsx +++ b/src/widgets/CapabilityText.tsx @@ -60,6 +60,9 @@ export class CapabilityText { [ElementWidgetCapabilities.CanChangeViewedRoom]: { [GENERIC_WIDGET_KIND]: _td("Change which room you're viewing"), }, + [MatrixCapabilities.MSC2931Navigate]: { + [GENERIC_WIDGET_KIND]: _td("Change which room you're viewing and use permalinks"), + }, }; private static stateSendRecvCaps: ISendRecvStaticCapText = {