From 2be1cc9f854c4ffcbfdbc69e2a94facf35edf960 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 27 Sep 2016 09:56:31 +0100 Subject: [PATCH] Give DMRoomMap an explicit makeShared Otherwise it will hang on to the old state client on logout. --- src/Lifecycle.js | 2 +- src/utils/DMRoomMap.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index cf1feea8c6..62fbe5f929 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -318,7 +318,7 @@ export function startMatrixClient() { Notifier.start(); UserActivity.start(); Presence.start(); - DMRoomMap.shared().start(); + DMRoomMap.makeShared().start(); MatrixClientPeg.start(); } diff --git a/src/utils/DMRoomMap.js b/src/utils/DMRoomMap.js index 8209023b3c..d6242719ba 100644 --- a/src/utils/DMRoomMap.js +++ b/src/utils/DMRoomMap.js @@ -41,15 +41,21 @@ export default class DMRoomMap { } } + /** + * Makes and returns a new shared instance that can then be accessed + * with shared(). This returned instance is not automatically started. + */ + static makeShared() { + DMRoomMap._sharedInstance = new DMRoomMap(MatrixClientPeg.get()); + return DMRoomMap._sharedInstance; + } + /** * Returns a shared instance of the class * that uses the singleton matrix client * The shared instance must be started before use. */ static shared() { - if (!DMRoomMap._sharedInstance) { - DMRoomMap._sharedInstance = new DMRoomMap(MatrixClientPeg.get()); - } return DMRoomMap._sharedInstance; } @@ -63,8 +69,8 @@ export default class DMRoomMap { } _onAccountData(ev) { - this.userToRooms = this.matrixClient.getAccountData('m.direct').getContent(); if (ev.getType() == 'm.direct') { + this.userToRooms = this.matrixClient.getAccountData('m.direct').getContent(); this._populateRoomToUser(); } }