Add managed hybrid call widgets when supported
If your homeserver is configured with an experiment `widget_build_url`, this will take over the functionality of the call buttons and turn them into a general widget installer.
This commit is contained in:
parent
241955f7c2
commit
2c313e0c5e
5 changed files with 131 additions and 2 deletions
|
@ -16,10 +16,15 @@ limitations under the License.
|
|||
|
||||
import {MatrixClientPeg} from '../MatrixClientPeg';
|
||||
|
||||
const CALL_BEHAVIOUR_WK_KEY = "io.element.call_behaviour";
|
||||
const E2EE_WK_KEY = "io.element.e2ee";
|
||||
const E2EE_WK_KEY_DEPRECATED = "im.vector.riot.e2ee";
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
export interface ICallBehaviourWellKnown {
|
||||
widget_build_url?: string;
|
||||
}
|
||||
|
||||
export interface IE2EEWellKnown {
|
||||
default?: boolean;
|
||||
secure_backup_required?: boolean;
|
||||
|
@ -27,6 +32,11 @@ export interface IE2EEWellKnown {
|
|||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
export function getCallBehaviourWellKnown(): ICallBehaviourWellKnown {
|
||||
const clientWellKnown = MatrixClientPeg.get().getClientWellKnown();
|
||||
return clientWellKnown?.[CALL_BEHAVIOUR_WK_KEY];
|
||||
}
|
||||
|
||||
export function getE2EEWellKnown(): IE2EEWellKnown {
|
||||
const clientWellKnown = MatrixClientPeg.get().getClientWellKnown();
|
||||
if (clientWellKnown && clientWellKnown[E2EE_WK_KEY]) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import {Room} from "matrix-js-sdk/src/models/room";
|
|||
import {WidgetType} from "../widgets/WidgetType";
|
||||
import {objectClone} from "./objects";
|
||||
import {_t} from "../languageHandler";
|
||||
import {Capability, IWidgetData, MatrixCapabilities} from "matrix-widget-api";
|
||||
import {Capability, IWidget, IWidgetData, MatrixCapabilities} from "matrix-widget-api";
|
||||
import {IApp} from "../stores/WidgetStore";
|
||||
|
||||
// How long we wait for the state event echo to come back from the server
|
||||
|
@ -297,6 +297,16 @@ export default class WidgetUtils {
|
|||
content = {};
|
||||
}
|
||||
|
||||
return WidgetUtils.setRoomWidgetContent(roomId, widgetId, content);
|
||||
}
|
||||
|
||||
static setRoomWidgetContent(
|
||||
roomId: string,
|
||||
widgetId: string,
|
||||
content: IWidget,
|
||||
) {
|
||||
const addingWidget = !!content.url;
|
||||
|
||||
WidgetEchoStore.setRoomWidgetEcho(roomId, widgetId, content);
|
||||
|
||||
const client = MatrixClientPeg.get();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue