[Store] Correct storing of accoundata
This commit is contained in:
parent
006c5a756f
commit
8b8232d2ba
|
@ -203,21 +203,10 @@ class Store {
|
||||||
/// Stores an UserUpdate object in the database. Must be called inside of
|
/// Stores an UserUpdate object in the database. Must be called inside of
|
||||||
/// [transaction].
|
/// [transaction].
|
||||||
Future<void> storeUserEventUpdate(UserUpdate userUpdate) {
|
Future<void> storeUserEventUpdate(UserUpdate userUpdate) {
|
||||||
switch (userUpdate.eventType) {
|
txn.rawInsert("INSERT OR REPLACE INTO AccountData VALUES(?, ?)", [
|
||||||
case "m.direct":
|
userUpdate.eventType,
|
||||||
if (userUpdate.content["content"] is Map<String, dynamic>) {
|
json.encode(userUpdate.content["content"]),
|
||||||
final Map<String, dynamic> directMap = userUpdate.content["content"];
|
]);
|
||||||
directMap.forEach((String key, dynamic value) {
|
|
||||||
if (value is List<dynamic> && value.length > 0)
|
|
||||||
for (int i = 0; i < value.length; i++) {
|
|
||||||
txn.rawUpdate(
|
|
||||||
"UPDATE Rooms SET direct_chat_matrix_id=? WHERE id=?",
|
|
||||||
[key, value[i]]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,9 +275,7 @@ class Store {
|
||||||
json.encode(eventContent["content"]),
|
json.encode(eventContent["content"]),
|
||||||
]);
|
]);
|
||||||
} else
|
} else
|
||||||
txn.rawInsert(
|
txn.rawInsert("INSERT OR REPLACE INTO RoomAccountData VALUES(?, ?, ?)", [
|
||||||
"INSERT OR REPLACE INTO RoomAccountData VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
||||||
[
|
|
||||||
eventContent["type"],
|
eventContent["type"],
|
||||||
chat_id,
|
chat_id,
|
||||||
json.encode(eventContent["content"]),
|
json.encode(eventContent["content"]),
|
||||||
|
|
Loading…
Reference in a new issue