fix: Pick right DM room, if multiple are set
This commit is contained in:
parent
588d7eb1a6
commit
b0043ea0e4
|
|
@ -199,12 +199,25 @@ class Client extends MatrixApi {
|
||||||
if (accountData['m.direct'] != null &&
|
if (accountData['m.direct'] != null &&
|
||||||
accountData['m.direct'].content[userId] is List<dynamic> &&
|
accountData['m.direct'].content[userId] is List<dynamic> &&
|
||||||
accountData['m.direct'].content[userId].length > 0) {
|
accountData['m.direct'].content[userId].length > 0) {
|
||||||
|
final potentialRooms = <Room>{};
|
||||||
for (final roomId in accountData['m.direct'].content[userId]) {
|
for (final roomId in accountData['m.direct'].content[userId]) {
|
||||||
final room = getRoomById(roomId);
|
final room = getRoomById(roomId);
|
||||||
if (room != null && room.membership == Membership.join) {
|
if (room != null && room.membership == Membership.join) {
|
||||||
return roomId;
|
potentialRooms.add(room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (potentialRooms.isNotEmpty) {
|
||||||
|
return potentialRooms
|
||||||
|
.fold(
|
||||||
|
null,
|
||||||
|
(prev, r) => prev == null
|
||||||
|
? r
|
||||||
|
: (prev.lastEvent.originServerTs <
|
||||||
|
r.lastEvent.originServerTs
|
||||||
|
? r
|
||||||
|
: prev))
|
||||||
|
.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0; i < rooms.length; i++) {
|
for (var i = 0; i < rooms.length; i++) {
|
||||||
if (rooms[i].membership == Membership.invite &&
|
if (rooms[i].membership == Membership.invite &&
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue