Merge pull request #1225 from vector-im/dbkr/lk_url_matroyshka

Add the livekit URL in matroyshka mode
This commit is contained in:
David Baker
2023-07-11 09:48:01 +01:00
committed by GitHub

View File

@@ -23,6 +23,7 @@ import type { MatrixClient } from "matrix-js-sdk/src/client";
import type { IWidgetApiRequest } from "matrix-widget-api"; import type { IWidgetApiRequest } from "matrix-widget-api";
import { LazyEventEmitter } from "./LazyEventEmitter"; import { LazyEventEmitter } from "./LazyEventEmitter";
import { getUrlParams } from "./UrlParams"; import { getUrlParams } from "./UrlParams";
import { Config } from "./config/Config";
// Subset of the actions in matrix-react-sdk // Subset of the actions in matrix-react-sdk
export enum ElementWidgetActions { export enum ElementWidgetActions {
@@ -156,9 +157,35 @@ export const widget: WidgetHelpers | null = (() => {
timelineSupport: true, timelineSupport: true,
useE2eForGroupCall: e2eEnabled, useE2eForGroupCall: e2eEnabled,
fallbackICEServerAllowed: allowIceFallback, fallbackICEServerAllowed: allowIceFallback,
// XXX: The client expects the list of foci in its constructor, but we don't
// know this until we fetch the config file. However, we can't wait to construct
// the client object or we'll miss the 'capabilities' request from the host app.
// As of writing this, I have made the embedded widget client send the 'contentLoaded'
// message so that we can use the widget API in less racy mode, but we need to change
// element-web to use waitForIFrameLoad=false. Once that change has rolled out,
// we can just start the client after we've fetched the config.
foci: [],
} }
); );
const clientPromise = client.startClient().then(() => client);
const clientPromise = new Promise<MatrixClient>((resolve) => {
(async () => {
// wait for the config file to be ready (we load very early on so it might not
// be otherwise)
await Config.init();
const livekit = Config.get().livekit;
const focus = livekit?.livekit_service_url;
// Now we've fetched the config, be evil and use the getter to inject the focus
// into the client (see above XXX).
if (focus) {
client.getFoci().push({
livekitServiceUrl: livekit.livekit_service_url,
});
}
await client.startClient();
resolve(client);
})();
});
return { api, lazyActions, client: clientPromise }; return { api, lazyActions, client: clientPromise };
} else { } else {