Wire up MSC2931 widget navigation
Fixes https://github.com/vector-im/element-web/issues/16006 **Requires https://github.com/matrix-org/matrix-widget-api/pull/27**
This commit is contained in:
parent
461b569278
commit
7e0cf5c783
5 changed files with 23 additions and 0 deletions
|
@ -584,6 +584,7 @@
|
||||||
"Send stickers into this room": "Send stickers into this room",
|
"Send stickers into this room": "Send stickers into this room",
|
||||||
"Send stickers into your active room": "Send stickers into your active 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": "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",
|
"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",
|
"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",
|
"Change the topic of your active room": "Change the topic of your active room",
|
||||||
|
|
|
@ -20,9 +20,16 @@ export enum ElementWidgetActions {
|
||||||
ClientReady = "im.vector.ready",
|
ClientReady = "im.vector.ready",
|
||||||
HangupCall = "im.vector.hangup",
|
HangupCall = "im.vector.hangup",
|
||||||
OpenIntegrationManager = "integration_manager_open",
|
OpenIntegrationManager = "integration_manager_open",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use MSC2931 instead
|
||||||
|
*/
|
||||||
ViewRoom = "io.element.view_room",
|
ViewRoom = "io.element.view_room",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use MSC2931 instead
|
||||||
|
*/
|
||||||
export interface IViewRoomApiRequest extends IWidgetApiRequest {
|
export interface IViewRoomApiRequest extends IWidgetApiRequest {
|
||||||
data: {
|
data: {
|
||||||
room_id: string; // eslint-disable-line camelcase
|
room_id: string; // eslint-disable-line camelcase
|
||||||
|
|
|
@ -15,5 +15,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export enum ElementWidgetCapabilities {
|
export enum ElementWidgetCapabilities {
|
||||||
|
/**
|
||||||
|
* @deprecated Use MSC2931 instead.
|
||||||
|
*/
|
||||||
CanChangeViewedRoom = "io.element.view_room",
|
CanChangeViewedRoom = "io.element.view_room",
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
import { CHAT_EFFECTS } from "../../effects";
|
import { CHAT_EFFECTS } from "../../effects";
|
||||||
import { containsEmoji } from "../../effects/utils";
|
import { containsEmoji } from "../../effects/utils";
|
||||||
import dis from "../../dispatcher/dispatcher";
|
import dis from "../../dispatcher/dispatcher";
|
||||||
|
import {tryTransformPermalinkToLocalHref} from "../../utils/permalinks/Permalinks";
|
||||||
|
|
||||||
// TODO: Purge this from the universe
|
// TODO: Purge this from the universe
|
||||||
|
|
||||||
|
@ -171,4 +172,12 @@ export class StopGapWidgetDriver extends WidgetDriver {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async navigate(uri: string): Promise<void> {
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,9 @@ export class CapabilityText {
|
||||||
[ElementWidgetCapabilities.CanChangeViewedRoom]: {
|
[ElementWidgetCapabilities.CanChangeViewedRoom]: {
|
||||||
[GENERIC_WIDGET_KIND]: _td("Change which room you're viewing"),
|
[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 = {
|
private static stateSendRecvCaps: ISendRecvStaticCapText = {
|
||||||
|
|
Loading…
Reference in a new issue