From 5933950f245eafa1d998ec218733c7d89fac68db Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Tue, 18 Jan 2022 16:17:59 +0100 Subject: [PATCH] add option to skip jitsi "join conference" screen Signed-off-by: Kerry Archibald --- src/vector/jitsi/index.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index f5993ff1b1..1ae4df75c4 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -47,6 +47,7 @@ let roomId: string; let openIdToken: IOpenIDCredentials; let roomName: string; let startAudioOnly: boolean; +let launchJitsiImmediately: boolean; let widgetApi: WidgetApi; let meetApi: any; // JitsiMeetExternalAPI @@ -57,6 +58,7 @@ let meetApi: any; // JitsiMeetExternalAPI const widgetQuery = new URLSearchParams(window.location.hash.substring(1)); // The widget spec on the other hand requires the widgetId and parentUrl to show up in the regular query string. const realQuery = new URLSearchParams(window.location.search.substring(1)); + const qsParam = (name: string, optional = false): string => { const vals = widgetQuery.has(name) ? widgetQuery.getAll(name) : realQuery.getAll(name); if (!optional && vals.length !== 1) { @@ -109,6 +111,11 @@ let meetApi: any; // JitsiMeetExternalAPI roomId = qsParam('roomId', true); roomName = qsParam('roomName', true); startAudioOnly = qsParam('isAudioOnly', true) === "true"; + launchJitsiImmediately = qsParam('launchImmediately', true) === "true"; + + if (launchJitsiImmediately) { + toggleConferenceVisibility(true); + } if (widgetApi) { await readyPromise; @@ -147,6 +154,10 @@ let meetApi: any; // JitsiMeetExternalAPI ); } + if (launchJitsiImmediately) { + joinConference(); + } + enableJoinButton(); // always enable the button } catch (e) { logger.error("Error setting up Jitsi widget", e); @@ -160,8 +171,13 @@ function enableJoinButton() { function switchVisibleContainers() { inConference = !inConference; - document.getElementById("jitsiContainer").style.visibility = inConference ? 'unset' : 'hidden'; - document.getElementById("joinButtonContainer").style.visibility = inConference ? 'hidden' : 'unset'; + if (!launchJitsiImmediately) { + toggleConferenceVisibility(inConference); + } +} +function toggleConferenceVisibility(isConferenceVisible) { + document.getElementById("jitsiContainer").style.visibility = isConferenceVisible ? 'unset' : 'hidden'; + document.getElementById("joinButtonContainer").style.visibility = isConferenceVisible ? 'hidden' : 'unset'; } /** @@ -263,5 +279,10 @@ function joinConference() { // event handler bound in HTML document.getElementById("jitsiContainer").innerHTML = ""; meetApi = null; + + // return to jitsi splash if immediate join enabled + if (launchJitsiImmediately) { + joinConference(); + } }); }