dont reassign userToRooms as we're just patching it up, also better check if we really have self DMs

This commit is contained in:
Bruno Windels 2018-08-30 11:50:57 +02:00
parent caff60d56d
commit 379ddfff29

View file

@ -72,8 +72,9 @@ export default class DMRoomMap {
if (ev.getType() == 'm.direct') { if (ev.getType() == 'm.direct') {
let userToRooms = this.matrixClient.getAccountData('m.direct').getContent(); let userToRooms = this.matrixClient.getAccountData('m.direct').getContent();
const myUserId = this.matrixClient.getUserId(); const myUserId = this.matrixClient.getUserId();
if (userToRooms[myUserId]) { const selfDMs = userToRooms[myUserId];
userToRooms = this._patchUpSelfDMs(userToRooms); if (selfDMs && selfDMs.length) {
this._patchUpSelfDMs(userToRooms);
this.matrixClient.setAccountData('m.direct', userToRooms); this.matrixClient.setAccountData('m.direct', userToRooms);
} }
this.userToRooms = userToRooms; this.userToRooms = userToRooms;