From 83d747f5f5299236c0d3f6d3a964796849bf163e Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 7 Aug 2019 08:50:05 +0200 Subject: [PATCH] [Store] Handle presences in store --- lib/src/Store.dart | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index 367ef9ce..236b79d9 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -203,10 +203,17 @@ class Store { /// Stores an UserUpdate object in the database. Must be called inside of /// [transaction]. Future storeUserEventUpdate(UserUpdate userUpdate) { - txn.rawInsert("INSERT OR REPLACE INTO AccountData VALUES(?, ?)", [ - userUpdate.eventType, - json.encode(userUpdate.content["content"]), - ]); + if (userUpdate.type == "account_data") + txn.rawInsert("INSERT OR REPLACE INTO AccountData VALUES(?, ?)", [ + userUpdate.eventType, + json.encode(userUpdate.content["content"]), + ]); + else if (userUpdate.type == "presence") + txn.rawInsert("INSERT OR REPLACE INTO Presence VALUES(?, ?)", [ + userUpdate.eventType, + userUpdate.content["sender"], + json.encode(userUpdate.content["content"]), + ]); return null; }