From e73d33a5e82b320273378d788438793909937cd0 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 27 Jun 2019 10:30:26 +0200 Subject: [PATCH] [Event] Refactoring --- lib/src/Store.dart | 4 ++-- lib/src/Timeline.dart | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index 32fd1440..e7cfc218 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -224,9 +224,9 @@ class Store { txn.rawDelete( "DELETE FROM Events WHERE id=?", [eventContent["event_id"]]); } else if ((status == 1 || status == -1) && - eventUpdate.content["txid"] is String) + eventContent["txid"] is String) txn.rawUpdate("UPDATE Events SET status=?, id=?, WHERE id=?", - [status, eventContent["event_id"], eventUpdate.content["txid"]]); + [status, eventContent["event_id"], eventContent["txid"]]); else txn.rawInsert( "INSERT OR REPLACE INTO Events VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", [ diff --git a/lib/src/Timeline.dart b/lib/src/Timeline.dart index e01802fd..9933bad7 100644 --- a/lib/src/Timeline.dart +++ b/lib/src/Timeline.dart @@ -47,9 +47,10 @@ class Timeline { int i; for (i = 0; i < events.length; i++) { if (events[i].content.containsKey("txid") && - events[i].content["txid"] == txid || + (txid != null && events[i].content["txid"] == txid) || events[i].id == event_id || - (events[i].content["txid"] == unsigned_txid)) break; + (unsigned_txid != null && events[i].content["txid"] == unsigned_txid)) + break; } return i; }