From d5a6ba225a9ef3c0577f9e640cb662d5ca3fe62c Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 13 Jun 2017 17:35:09 +0100 Subject: [PATCH] DM guessing: prefer oldest joined member In the DM guessing code, prefer the oldest joined member if there's anyone in the rom other than us. Otherwise, fall back to the old behaviour. Fixes https://github.com/vector-im/riot-web/issues/4288 --- src/Rooms.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Rooms.js b/src/Rooms.js index 16b5ab9ee2..3ac7c68533 100644 --- a/src/Rooms.js +++ b/src/Rooms.js @@ -144,7 +144,18 @@ export function guessDMRoomTarget(room, me) { let oldestTs; let oldestUser; - // Pick the user who's been here longest (and isn't us) + // Pick the joined user who's been here longest (and isn't us), + for (const user of room.getJoinedMembers()) { + if (user.userId == me.userId) continue; + + if (oldestTs === undefined || user.events.member.getTs() < oldestTs) { + oldestUser = user; + oldestTs = user.events.member.getTs(); + } + } + if (oldestUser) return oldestUser; + + // if there are no joined members other than us, use the oldest member for (const user of room.currentState.getMembers()) { if (user.userId == me.userId) continue;