Give DMRoomMap an explicit makeShared

Otherwise it will hang on to the old state client on logout.
pull/21833/head
David Baker 2016-09-27 09:56:31 +01:00
parent 690309adfc
commit 2be1cc9f85
2 changed files with 11 additions and 5 deletions

View File

@ -318,7 +318,7 @@ export function startMatrixClient() {
Notifier.start(); Notifier.start();
UserActivity.start(); UserActivity.start();
Presence.start(); Presence.start();
DMRoomMap.shared().start(); DMRoomMap.makeShared().start();
MatrixClientPeg.start(); MatrixClientPeg.start();
} }

View File

@ -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 * Returns a shared instance of the class
* that uses the singleton matrix client * that uses the singleton matrix client
* The shared instance must be started before use. * The shared instance must be started before use.
*/ */
static shared() { static shared() {
if (!DMRoomMap._sharedInstance) {
DMRoomMap._sharedInstance = new DMRoomMap(MatrixClientPeg.get());
}
return DMRoomMap._sharedInstance; return DMRoomMap._sharedInstance;
} }
@ -63,8 +69,8 @@ export default class DMRoomMap {
} }
_onAccountData(ev) { _onAccountData(ev) {
this.userToRooms = this.matrixClient.getAccountData('m.direct').getContent();
if (ev.getType() == 'm.direct') { if (ev.getType() == 'm.direct') {
this.userToRooms = this.matrixClient.getAccountData('m.direct').getContent();
this._populateRoomToUser(); this._populateRoomToUser();
} }
} }