Merge branch 'krille/minor-refactoring' into 'master'

Minor refactoring

See merge request famedly/famedlysdk!361
This commit is contained in:
Sorunome 2020-06-25 07:17:00 +00:00
commit 2cd4ab11ce
2 changed files with 8 additions and 23 deletions

View file

@ -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) {

View file

@ -255,23 +255,6 @@ class Database extends _$Database {
}
}
/// Stores an UserUpdate object in the database. Must be called inside of
/// [transaction].
Future<void> storeUserEventUpdate(
int clientId,
String type,
String eventType,
Map<String, dynamic> 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<void> storeEventUpdate(