the js-sdk is making some of its APIs asynchronous, and adding an `initCrypto`
method which you have to call.
Particular methods we need to worry about are:
* `getStoredDevice`
* `getStoredDevicesForUser`
* `getEventSenderDeviceInfo`
* `isEventSenderVerified`
It turns out that Firefox doesn't let you use indexeddb from private tabs,
*unless* you are *also* in a webworker. We need to either consistently use it
or not use it - so let's use it.
* don't just log errors without any context as to where they came from or what
they mean
* avoid the use of '%s' and multi-argument console.log because it looks awful
under karma.
Get rid of MatrixClientPeg.replaceUsingUrls, and instead create local,
temporary MatrixClients for the unauthed steps; we therefore only use
MatrixClientPeg for logged-in clients.
Don't clear localstorage when replacing the client: we clear it when logging out so this is just redundant, and since we now use replaceClient to unpickle a session from localstorage, this was blowing away all our setting on every refresh.
Also Move all of the localstorage code to Lifecycle (except device ID but this will probably be generated on the server soon anyway). We previously cleared localstorage on logout in Lifecycle so persist the session in Lifecycle.setLoggedIn() to be symmetrical.
This means that we don't create a spurious MatrixClient which is thrown away by
the SessionLoader (whilst still ensuring that the rehydrated matrixclient
follows the same code path as matrixclients created at other points in the
session load process).
Also try to refactor some of the login/logout code out of MatrixChat and into a separate Lifecycle.js. This still isn't great, but it at least gets some code out of MatrixClient.
Reintroduce replaceClient so we're not calling replaceUsingAccessToken without access tokens which is a bit silly.
Fix bug from previous commit (pass isGuest through)
Including getting rid of GuestAccess as it was basically doing nothing apart from remembering if we were a guest which may as well be done in the same place we save/restore everything else
In order that device_id is set when we register a new user (or, for that
matter, when we register as a guest), we need to make sure that device_id is
set on the temporary MatrixClient which is created before the user is logged
in - ie, that created by replaceUsingUrls.
In order to achieve this, I've basically removed the distinction between
replaceUsingAccessToken and replaceUsingUrls. There is a side-effect in that
the temporary MatrixClient now gets an e2e sessionStore, but I don't think that
is a bad thing.
1) custom HS/IS urls are now persisted in HTML5 local storage. As a result, all the login components now distinguish between default HS/IS URLs and custom specified ones again. (
2) custom HS/IS urls are synchronised between the instances of ServerConfig found in the Login, Registration and Forgot Password screens.
3) username are persisted over changing homeserver (but not password, to stop accidentally leaking passwords to the wrong server)
4) correctly interpret a blank URL field as meaning the placeholder text
5) when toggling custom URLs on and off, remember what the custom values were, and use the default URLs if custom mode is not engaged
also, guest access now upholds custom HS/IS URLs found in local storage rather than being limited to the server config ()
also adds assorted comments and improved console debug and a few minor cosmetic changes to the login components.
this commit sponsored by VS27...
Instead of using the Room's active timeline directly, use a
TimelineWindow. This shouldn't (yet) have much effect, beyond maybe making
scrollback after a gappy sync slightly more efficient.
For now, I have disabled the 'restoreScrollState' functionality. This will be
reinstated once I land the link-to-event code.