Merge branch 'krille/minor-refactoring' into 'master'
Minor refactoring See merge request famedly/famedlysdk!361
This commit is contained in:
commit
2cd4ab11ce
|
@ -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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue