From 210c925a0a88e2fe0ce5df91bd38ec5698b684d3 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 8 Sep 2021 11:33:36 +0200 Subject: [PATCH] fix: Do not handle sending event updates which are already synced This is an edge case which might occour on unstable data connections. The user sends an event and receives the sync before the response to the sending http request. This leads to duplicated events while the response actually should be ignored at this point. --- lib/src/database/hive_database.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/database/hive_database.dart b/lib/src/database/hive_database.dart index 2a4a6005..0ba951c9 100644 --- a/lib/src/database/hive_database.dart +++ b/lib/src/database/hive_database.dart @@ -828,6 +828,12 @@ class FamedlySdkHiveDatabase extends DatabaseApi { ?.tryGet(messageSendingStatusKey) ?? 2; + // Is this the response to a sending event which is already synced? Then + // there is nothing to do here. + if (newStatus != 2 && prevEvent?.status == 2) { + return; + } + final status = newStatus == -1 || prevEvent == null || prevEvent.status == null ? newStatus