Merge pull request #457 from matrix-org/dbkr/dont_crash_if_no_dm_rooms

Don't crash if no DM rooms with someone
This commit is contained in:
Matthew Hodgson 2016-09-09 18:09:40 +01:00 committed by GitHub
commit 8160613e01

View file

@ -32,7 +32,9 @@ export default class DMRoomMap {
}
getDMRoomsForUserId(userId) {
return this.userToRooms[userId];
// Here, we return the empty list if there are no rooms,
// since the number of conversations you have with this user is zero.
return this.userToRooms[userId] || [];
}
getUserIdForRoomId(roomId) {
@ -45,6 +47,8 @@ export default class DMRoomMap {
// is never called.
this._populateRoomToUser();
}
// Here, we return undefined if the room is not in the map:
// the room ID you gave is not a DM room for any user.
return this.roomToUser[roomId];
}