Fixes riot-web#4334
When we do a token login, don't carry on with the normal app startup
(transitioning to the loggedIn state etc) - instead tell the app about the
successful login and wait for it to redirect.
Replace onLoadCompleted with onTokenLoginCompleted so that the app can see what
it's supposed to be doing.
498ea53 made it so that the #/login URL fragment was prioritised over the token
params in the query string; unfortunately that also means that CAS login gets
stuck in a loop where you always get redirected back to the login view.
Prioritising the URL fragment over the token params may or may not be the
correct thing to, but I also think it's incorrect that we ask the CAS server to
redirect us back to #/login. Accordingly, the easiest fix here is just to clear
the URL fragment before redirecting to CAS.
and also things like the unsent message error and encryption
warning.
Stuff that we need to do at room view mount time had got moved into
a clause of the if statement in onHaveRoom and so wasn't being
executed.
Fixes https://github.com/vector-im/riot-web/issues/4327
MatrixChat is essentially a glorified state machine, with its states partially
determined by the loading, loggedIn and loggingIn state flags. If we actually
make each of the states implied by those flags an explicit 'view', then
everything gets much clearer.
'screen' is overloaded, as it us used for the parameter of `showScreen` (and,
by implication, `state.screenAfterLogin`). Attempt to clear up the confusion by
replacing 'screen' with 'view' and using some constants for the potential
values.
This should be a no-op!
If we successfully join, display a spinner until the js-sdk indicates (via room membership event or room event) that we can start using the room normally. A room event indicates we have never seen that room which means we need to use the new room object to clobber state.room. This is to make sure we replace the room that is set up for peeking with the room that can be used normally. For historical rooms, this isn't a problem.
This is a workaround for the fact that when peeking, the js-sdk calls onRoom, which is difficult to handle from the clients perspective because onRoom should only be called for rooms that you've never seen before. But if you peek a room that you've joined and left and get an onRoom, you run into trouble. You also can't just always use onRoomMembership because this won't be triggered for the first time you see the room. So we end up using a combination of both.
See https://github.com/matrix-org/matrix-js-sdk/issues/464 for discussion on improving this