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:
commit
8160613e01
1 changed files with 5 additions and 1 deletions
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue