From 8b8232d2bac2e7545d5a02a1fabe3db52d4a27b4 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 7 Aug 2019 08:47:53 +0200 Subject: [PATCH] [Store] Correct storing of accoundata --- lib/src/Store.dart | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index 2f23b2f..367ef9c 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -203,21 +203,10 @@ class Store { /// Stores an UserUpdate object in the database. Must be called inside of /// [transaction]. Future storeUserEventUpdate(UserUpdate userUpdate) { - switch (userUpdate.eventType) { - case "m.direct": - if (userUpdate.content["content"] is Map) { - final Map directMap = userUpdate.content["content"]; - directMap.forEach((String key, dynamic value) { - if (value is List && 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; - } + txn.rawInsert("INSERT OR REPLACE INTO AccountData VALUES(?, ?)", [ + userUpdate.eventType, + json.encode(userUpdate.content["content"]), + ]); return null; } @@ -286,13 +275,11 @@ class Store { json.encode(eventContent["content"]), ]); } else - txn.rawInsert( - "INSERT OR REPLACE INTO RoomAccountData VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", - [ - eventContent["type"], - chat_id, - json.encode(eventContent["content"]), - ]); + txn.rawInsert("INSERT OR REPLACE INTO RoomAccountData VALUES(?, ?, ?)", [ + eventContent["type"], + chat_id, + json.encode(eventContent["content"]), + ]); return null; }