Merge pull request #1087 from matrix-org/dbkr/dm_guess_oldest_joined

DM guessing: prefer oldest joined member
This commit is contained in:
David Baker 2017-06-14 10:30:46 +01:00 committed by GitHub
commit b4e216ba23

View file

@ -144,7 +144,18 @@ export function guessDMRoomTarget(room, me) {
let oldestTs; let oldestTs;
let oldestUser; 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()) { for (const user of room.currentState.getMembers()) {
if (user.userId == me.userId) continue; if (user.userId == me.userId) continue;