mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-03 20:36:57 +03:00
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
This commit is contained in:
parent
79c2977f13
commit
d5a6ba225a
1 changed files with 12 additions and 1 deletions
13
src/Rooms.js
13
src/Rooms.js
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue