@@ -104,6 +104,23 @@ describe('loading:', function () {
104104 }
105105 }
106106
107+ // Parse the given window.location and return parameters that can be used when calling
108+ // MatrixChat.showScreen(screen, params)
109+ function getScreenFromLocation ( location ) {
110+ const fragparts = parseQsFromFragment ( location ) ;
111+ return {
112+ screen : fragparts . location . substring ( 1 ) ,
113+ params : fragparts . params ,
114+ }
115+ }
116+
117+ function routeUrl ( location , matrixChat ) {
118+ console . log ( Date . now ( ) + "Routing URL " + location ) ;
119+ const s = getScreenFromLocation ( location ) ;
120+ console . log ( "Showing screen" , s ) ;
121+ matrixChat . showScreen ( s . screen , s . params ) ;
122+ }
123+
107124 const MatrixChat = sdk . getComponent ( 'structures.MatrixChat' ) ;
108125 const fragParts = parseQsFromFragment ( windowLocation ) ;
109126 var params = parseQs ( windowLocation ) ;
@@ -118,16 +135,10 @@ describe('loading:', function () {
118135 startingFragmentQueryParams = { fragParts . params }
119136 enableGuest = { true }
120137 onLoadCompleted = { loadCompleteDefer . resolve }
138+ initialScreenAfterLogin = { getScreenFromLocation ( windowLocation ) }
121139 /> , parentDiv
122140 ) ;
123141
124- function routeUrl ( location , matrixChat ) {
125- console . log ( Date . now ( ) + " Routing URL " + location ) ;
126- var fragparts = parseQsFromFragment ( location ) ;
127- matrixChat . showScreen ( fragparts . location . substring ( 1 ) ,
128- fragparts . params ) ;
129- }
130-
131142 // pause for a cycle, then simulate the window.onload handler
132143 window . setTimeout ( ( ) => {
133144 console . log ( Date . now ( ) + " simulating window.onload" ) ;
@@ -476,7 +487,8 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
476487 retryCount = 0 ;
477488 }
478489
479- if ( ! matrixChat . state . ready ) {
490+ if ( matrixChat . state . loading ||
491+ ! ( matrixChat . state . loggedIn && matrixChat . state . ready ) ) {
480492 console . log ( Date . now ( ) + " Awaiting room view: not ready yet." ) ;
481493 if ( retryCount >= retryLimit ) {
482494 throw new Error ( "MatrixChat still not ready after " +
0 commit comments