diff --git a/package.json b/package.json index eb97ff1995..1316b26030 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "linkifyjs": "^2.1.9", "lodash": "^4.17.19", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", - "matrix-widget-api": "^0.1.0-beta.10", + "matrix-widget-api": "0.1.0-beta.11", "minimist": "^1.2.5", "pako": "^1.0.11", "parse5": "^5.1.1", diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 71b390f0fc..274bd247e2 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, message, or user you're viewing": "Change which room, message, or user you're viewing", "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..273d22dc81 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, message, or user you're viewing"), + }, }; private static stateSendRecvCaps: ISendRecvStaticCapText = { diff --git a/yarn.lock b/yarn.lock index eefe6e071e..d8f4278ae0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1809,6 +1809,11 @@ resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== +"@types/events@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" + integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== + "@types/fbemitter@*": version "2.0.32" resolved "https://registry.yarnpkg.com/@types/fbemitter/-/fbemitter-2.0.32.tgz#8ed204da0f54e9c8eaec31b1eec91e25132d082c" @@ -6580,11 +6585,12 @@ matrix-react-test-utils@^0.2.2: resolved "https://registry.yarnpkg.com/matrix-react-test-utils/-/matrix-react-test-utils-0.2.2.tgz#c87144d3b910c7edc544a6699d13c7c2bf02f853" integrity sha512-49+7gfV6smvBIVbeloql+37IeWMTD+fiywalwCqk8Dnz53zAFjKSltB3rmWHso1uecLtQEcPtCijfhzcLXAxTQ== -matrix-widget-api@^0.1.0-beta.10: - version "0.1.0-beta.10" - resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.10.tgz#2e4d658d90ff3152c5567089b4ddd21fb44ec1dd" - integrity sha512-yX2UURjM1zVp7snPiOFcH9+FDBdHfAdt5HEAyDUHGJ7w/F2zOtcK/y0dMlZ1+XhxY7Wv0IBZH0US8X/ioJRX1A== +matrix-widget-api@0.1.0-beta.11: + version "0.1.0-beta.11" + resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.11.tgz#3658e244bf82eebea36e64475ebfce86b778b476" + integrity sha512-RxIghopRKTQdmYMJzZg/QR+wcPcKe9S1pZZ31zN/M1LKsvTLThBYdMcP1idKh7MkhpO9eCdCVjJOMJTrqxNzbQ== dependencies: + "@types/events" "^3.0.0" events "^3.2.0" mdast-util-compact@^1.0.0: