From f1ed750246c6eaf6c3d9a11777f0321b455df163 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 9 Sep 2016 17:35:35 +0100 Subject: [PATCH] Don't crash if no DM rooms with someone ...when opening MemberInfo. getDMRoomsForUserId should always return a valid list, since it's a list of what DM rooms you have with somebody. --- src/utils/DMRoomMap.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/DMRoomMap.js b/src/utils/DMRoomMap.js index d92ae87e64..95b4edb546 100644 --- a/src/utils/DMRoomMap.js +++ b/src/utils/DMRoomMap.js @@ -37,10 +37,14 @@ 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) { + // 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]; } }