[Client] Directchatroom should exist

This commit is contained in:
Christian Pauly 2019-08-29 11:03:43 +02:00
parent f885dfbecc
commit 37866359be
2 changed files with 15 additions and 6 deletions

View file

@ -123,12 +123,14 @@ class Client {
/// Returns the (first) room ID from the store which is a private chat with the user [userId].
/// Returns null if there is none.
String getDirectChatFromUserId(String userId) =>
accountData["m.direct"] != null &&
accountData["m.direct"].content[userId] is List<dynamic> &&
accountData["m.direct"].content[userId].length > 0
? accountData["m.direct"].content[userId][0]
: null;
String getDirectChatFromUserId(String userId) => accountData["m.direct"] !=
null &&
accountData["m.direct"].content[userId] is List<dynamic> &&
accountData["m.direct"].content[userId].length > 0 &&
roomList.getRoomById(accountData["m.direct"].content[userId][0]) !=
null
? accountData["m.direct"].content[userId][0]
: null;
/// Checks the supported versions of the Matrix protocol and the supported
/// login types. Returns false if the server is not compatible with the

View file

@ -78,6 +78,13 @@ class RoomList {
return null;
}
Room getRoomById(String id) {
for (int j = 0; j < rooms.length; j++) {
if (rooms[j].id == id) return rooms[j];
}
return null;
}
void _handleRoomUpdate(RoomUpdate chatUpdate) {
// Update the chat list item.
// Search the room in the rooms