Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit d5a6ba2

Browse files
committed
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 element-hq/element-web#4288
1 parent 79c2977 commit d5a6ba2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Rooms.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,18 @@ export function guessDMRoomTarget(room, me) {
144144
let oldestTs;
145145
let oldestUser;
146146

147-
// Pick the user who's been here longest (and isn't us)
147+
// Pick the joined user who's been here longest (and isn't us),
148+
for (const user of room.getJoinedMembers()) {
149+
if (user.userId == me.userId) continue;
150+
151+
if (oldestTs === undefined || user.events.member.getTs() < oldestTs) {
152+
oldestUser = user;
153+
oldestTs = user.events.member.getTs();
154+
}
155+
}
156+
if (oldestUser) return oldestUser;
157+
158+
// if there are no joined members other than us, use the oldest member
148159
for (const user of room.currentState.getMembers()) {
149160
if (user.userId == me.userId) continue;
150161

0 commit comments

Comments
 (0)