diff --git a/lib/src/client.dart b/lib/src/client.dart index 62bee50..10a8e91 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -722,11 +722,11 @@ class Client { if (sync.presence != null) { for (final newPresence in sync.presence) { if (database != null) { - await database.storeUserEventUpdate( + await database.storePresence( id, - 'presence', newPresence.type, - newPresence.toJson(), + newPresence.senderId, + jsonEncode(newPresence.toJson()), ); } presences[newPresence.senderId] = newPresence; @@ -736,15 +736,17 @@ class Client { if (sync.accountData != null) { for (final newAccountData in sync.accountData) { if (database != null) { - await database.storeUserEventUpdate( + await database.storeAccountData( id, - 'account_data', newAccountData.type, - newAccountData.toJson(), + jsonEncode(newAccountData.toJson()), ); } accountData[newAccountData.type] = newAccountData; if (onAccountData != null) onAccountData.add(newAccountData); + if (newAccountData.type == 'm.direct') { + _sortRooms(); + } } } if (sync.deviceLists != null) { diff --git a/lib/src/database/database.dart b/lib/src/database/database.dart index 8abde1d..136ce64 100644 --- a/lib/src/database/database.dart +++ b/lib/src/database/database.dart @@ -255,23 +255,6 @@ class Database extends _$Database { } } - /// Stores an UserUpdate object in the database. Must be called inside of - /// [transaction]. - Future storeUserEventUpdate( - int clientId, - String type, - String eventType, - Map content, - ) async { - if (type == 'account_data') { - await storeAccountData( - clientId, eventType, json.encode(content['content'])); - } else if (type == 'presence') { - await storePresence(clientId, eventType, content['sender'], - json.encode(content['content'])); - } - } - /// Stores an EventUpdate object in the database. Must be called inside of /// [transaction]. Future storeEventUpdate(