mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
Make widget API use optional
So we can work when popped out into a browser
This commit is contained in:
parent
421fcb115f
commit
0bf05e3c7b
1 changed files with 18 additions and 8 deletions
|
@ -49,11 +49,19 @@ let widgetApi: WidgetApi;
|
||||||
return <string>query[name];
|
return <string>query[name];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If we have these params, expect a widget API to be available (ie. to be in an iframe
|
||||||
|
// inside a matrix client). Otherwise, assume we're on our own, eg. have been popped
|
||||||
|
// out into a browser.
|
||||||
|
const parentUrl = qsParam('parentUrl', true);
|
||||||
|
const widgetId = qsParam('widgetId', true);
|
||||||
|
|
||||||
// Set this up as early as possible because Riot will be hitting it almost immediately.
|
// Set this up as early as possible because Riot will be hitting it almost immediately.
|
||||||
widgetApi = new WidgetApi(qsParam('parentUrl'), qsParam('widgetId'), [
|
if (parentUrl && widgetId) {
|
||||||
Capability.AlwaysOnScreen,
|
widgetApi = new WidgetApi(qsParam('parentUrl'), qsParam('widgetId'), [
|
||||||
]);
|
Capability.AlwaysOnScreen,
|
||||||
widgetApi.expectingExplicitReady = true;
|
]);
|
||||||
|
widgetApi.expectingExplicitReady = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Populate the Jitsi params now
|
// Populate the Jitsi params now
|
||||||
jitsiDomain = qsParam('conferenceDomain');
|
jitsiDomain = qsParam('conferenceDomain');
|
||||||
|
@ -62,8 +70,10 @@ let widgetApi: WidgetApi;
|
||||||
avatarUrl = qsParam('avatarUrl', true); // http not mxc
|
avatarUrl = qsParam('avatarUrl', true); // http not mxc
|
||||||
userId = qsParam('userId');
|
userId = qsParam('userId');
|
||||||
|
|
||||||
await widgetApi.waitReady();
|
if (widgetApi) {
|
||||||
await widgetApi.setAlwaysOnScreen(false); // start off as detachable from the screen
|
await widgetApi.waitReady();
|
||||||
|
await widgetApi.setAlwaysOnScreen(false); // start off as detachable from the screen
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: register widgetApi listeners for PTT controls (https://github.com/vector-im/riot-web/issues/12795)
|
// TODO: register widgetApi listeners for PTT controls (https://github.com/vector-im/riot-web/issues/12795)
|
||||||
|
|
||||||
|
@ -85,7 +95,7 @@ function joinConference() { // event handler bound in HTML
|
||||||
switchVisibleContainers();
|
switchVisibleContainers();
|
||||||
|
|
||||||
// noinspection JSIgnoredPromiseFromCall
|
// noinspection JSIgnoredPromiseFromCall
|
||||||
widgetApi.setAlwaysOnScreen(true); // ignored promise because we don't care if it works
|
if (widgetApi) widgetApi.setAlwaysOnScreen(true); // ignored promise because we don't care if it works
|
||||||
|
|
||||||
const meetApi = new JitsiMeetExternalAPI(jitsiDomain, {
|
const meetApi = new JitsiMeetExternalAPI(jitsiDomain, {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
@ -107,7 +117,7 @@ function joinConference() { // event handler bound in HTML
|
||||||
switchVisibleContainers();
|
switchVisibleContainers();
|
||||||
|
|
||||||
// noinspection JSIgnoredPromiseFromCall
|
// noinspection JSIgnoredPromiseFromCall
|
||||||
widgetApi.setAlwaysOnScreen(false); // ignored promise because we don't care if it works
|
if (widgetApi) widgetApi.setAlwaysOnScreen(false); // ignored promise because we don't care if it works
|
||||||
|
|
||||||
document.getElementById("jitsiContainer").innerHTML = "";
|
document.getElementById("jitsiContainer").innerHTML = "";
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue