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.
This commit is contained in:
Christian Pauly 2021-09-08 11:33:36 +02:00
parent 8548a3ab28
commit 210c925a0a
1 changed files with 6 additions and 0 deletions

View File

@ -828,6 +828,12 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
?.tryGet<int>(messageSendingStatusKey) ?? ?.tryGet<int>(messageSendingStatusKey) ??
2; 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 = final status =
newStatus == -1 || prevEvent == null || prevEvent.status == null newStatus == -1 || prevEvent == null || prevEvent.status == null
? newStatus ? newStatus