diff --git a/src/Lifecycle.js b/src/Lifecycle.js index b50e96b298..4393c29d37 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -22,11 +22,7 @@ import dis from './dispatcher'; /** * Transitions to a logged-in state using the given credentials - * @param {string} credentials.homeserverUrl The base HS URL - * @param {string} credentials.identityServerUrl The base IS URL - * @param {string} credentials.userId The full Matrix User ID - * @param {string} credentials.accessToken The session access token - * @param {boolean} credentials.guest True if the session is a guest session + * @param {MatrixClientCreds} credentials The credentials to use */ function setLoggedIn(credentials) { credentials.guest = Boolean(credentials.guest); @@ -80,11 +76,7 @@ function startMatrixClient() { UserActivity.start(); Presence.start(); - // the react sdk doesn't work without this, so don't allow - // it to be overridden (and modify the global object so at - // at least the app can see we've changed it) - MatrixClientPeg.opts.pendingEventOrdering = "detached"; - MatrixClientPeg.get().startClient(MatrixClientPeg.opts); + MatrixClientPeg.start(); } function onLoggedOut() { diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index c8b015f99f..e6d0e7f3f7 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -17,6 +17,7 @@ limitations under the License. 'use strict'; import Matrix from 'matrix-js-sdk'; +import utils from 'matrix-js-sdk/lib/utils'; const localStorage = window.localStorage; @@ -49,10 +50,10 @@ class MatrixClientPeg { constructor() { this.matrixClient = null; - // These are the default options used when Lifecycle.js - // starts the client. These can be altered at any - // time up to after the 'will_start_client' event is - // finished processing. + // These are the default options used when when the + // client is started in 'start'. These can be altered + // at any time up to after the 'will_start_client' + // event is finished processing. this.opts = { initialSyncLimit: 20, }; @@ -88,6 +89,13 @@ class MatrixClientPeg { ); } + start() { + const opts = utils.deepCopy(this.opts); + // the react sdk doesn't work without this, so don't allow + opts.pendingEventOrdering = "detached"; + this.get().startClient(opts); + } + _replaceClient(hs_url, is_url, user_id, access_token, isGuest) { if (localStorage) { try {