Merge pull request #2466 from matrix-org/dbkr/fix_direct_chat_button

Fix settings direct chat
pull/21833/head
David Baker 2019-01-21 16:28:02 +00:00 committed by GitHub
commit 250c7e0c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -159,6 +159,10 @@ export function setDMRoom(roomId, userId) {
/**
* Given a room, estimate which of its members is likely to
* be the target if the room were a DM room and return that user.
*
* @param {Object} room Target room
* @param {string} myUserId User ID of the current user
* @returns {string} User ID of the user that the room is probably a DM with
*/
function guessDMRoomTargetId(room, myUserId) {
let oldestTs;
@ -173,7 +177,7 @@ function guessDMRoomTargetId(room, myUserId) {
oldestTs = user.events.member.getTs();
}
}
if (oldestUser) return oldestUser;
if (oldestUser) return oldestUser.userId;
// if there are no joined members other than us, use the oldest member
for (const user of room.currentState.getMembers()) {
@ -186,5 +190,5 @@ function guessDMRoomTargetId(room, myUserId) {
}
if (oldestUser === undefined) return myUserId;
return oldestUser;
return oldestUser.userId;
}