@@ -49,12 +49,19 @@ let widgetApi: WidgetApi;
4949 return < string > query [ name ] ;
5050 } ;
5151
52+ // If we have these params, expect a widget API to be available (ie. to be in an iframe
53+ // inside a matrix client). Otherwise, assume we're on our own, eg. have been popped
54+ // out into a browser.
55+ const parentUrl = qsParam ( 'parentUrl' , true ) ;
56+ const widgetId = qsParam ( 'widgetId' , true ) ;
57+
5258 // Set this up as early as possible because Riot will be hitting it almost immediately.
53- widgetApi = new WidgetApi ( qsParam ( 'parentUrl' ) , qsParam ( 'widgetId' ) , [
54- Capability . AlwaysOnScreen ,
55- Capability . GetRiotWebConfig ,
56- ] ) ;
57- widgetApi . expectingExplicitReady = true ;
59+ if ( parentUrl && widgetId ) {
60+ widgetApi = new WidgetApi ( qsParam ( 'parentUrl' ) , qsParam ( 'widgetId' ) , [
61+ Capability . AlwaysOnScreen ,
62+ ] ) ;
63+ widgetApi . expectingExplicitReady = true ;
64+ }
5865
5966 // Populate the Jitsi params now
6067 jitsiDomain = qsParam ( 'conferenceDomain' ) ;
@@ -63,16 +70,10 @@ let widgetApi: WidgetApi;
6370 avatarUrl = qsParam ( 'avatarUrl' , true ) ; // http not mxc
6471 userId = qsParam ( 'userId' ) ;
6572
66- await widgetApi . waitReady ( ) ;
67- await widgetApi . setAlwaysOnScreen ( false ) ; // start off as detachable from the screen
68-
69- const riotConfig = await widgetApi . getRiotConfig ( ) ;
70-
71- // Get the Jitsi Meet API loaded up as fast as possible, but ensure that the widget's postMessage
72- // receiver (WidgetApi) is up and running first.
73- const scriptTag = document . createElement ( "script" ) ;
74- scriptTag . src = riotConfig [ 'jitsi' ] [ 'externalApiUrl' ] ;
75- document . body . appendChild ( scriptTag ) ;
73+ if ( widgetApi ) {
74+ await widgetApi . waitReady ( ) ;
75+ await widgetApi . setAlwaysOnScreen ( false ) ; // start off as detachable from the screen
76+ }
7677
7778 // TODO: register widgetApi listeners for PTT controls (https://github.com/vector-im/riot-web/issues/12795)
7879
@@ -94,7 +95,7 @@ function joinConference() { // event handler bound in HTML
9495 switchVisibleContainers ( ) ;
9596
9697 // noinspection JSIgnoredPromiseFromCall
97- widgetApi . setAlwaysOnScreen ( true ) ; // ignored promise because we don't care if it works
98+ if ( widgetApi ) widgetApi . setAlwaysOnScreen ( true ) ; // ignored promise because we don't care if it works
9899
99100 const meetApi = new JitsiMeetExternalAPI ( jitsiDomain , {
100101 width : "100%" ,
@@ -116,7 +117,7 @@ function joinConference() { // event handler bound in HTML
116117 switchVisibleContainers ( ) ;
117118
118119 // noinspection JSIgnoredPromiseFromCall
119- widgetApi . setAlwaysOnScreen ( false ) ; // ignored promise because we don't care if it works
120+ if ( widgetApi ) widgetApi . setAlwaysOnScreen ( false ) ; // ignored promise because we don't care if it works
120121
121122 document . getElementById ( "jitsiContainer" ) . innerHTML = "" ;
122123 } ) ;
0 commit comments