Merge branch 'soru/direct-chats' into 'master'

potentially fix direct chats going missing

Closes ChristianPauly/fluffychat-flutter#86

See merge request famedly/famedlysdk!346
This commit is contained in:
Christian Pauly 2020-06-22 06:48:30 +00:00
commit aea86aaf10

View file

@ -168,13 +168,12 @@ class Client {
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) {
if (getRoomById(accountData['m.direct'].content[userId][0]) != null) { for (final roomId in accountData['m.direct'].content[userId]) {
return accountData['m.direct'].content[userId][0]; final room = getRoomById(roomId);
if (room != null && room.membership == Membership.join) {
return roomId;
}
} }
(accountData['m.direct'].content[userId] as List<dynamic>)
.remove(accountData['m.direct'].content[userId][0]);
api.setAccountData(userId, 'm.direct', directChats);
return getDirectChatFromUserId(userId);
} }
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 &&