From 3f4530f299a6cbaa2b025cd41aab03cb7c78ec15 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Tue, 21 Jun 2022 15:48:53 -0700 Subject: [PATCH] fix first sync --- lib/models/remoteserver.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/models/remoteserver.dart b/lib/models/remoteserver.dart index f53ef31b..9f2491c4 100644 --- a/lib/models/remoteserver.dart +++ b/lib/models/remoteserver.dart @@ -52,6 +52,12 @@ class RemoteServerInfoState extends ChangeNotifier { void updateSyncProgressFor(DateTime point) { var range = lastPreSyncMessagTime.toUtc().difference(DateTime.now().toUtc()); var pointFromStart = lastPreSyncMessagTime.toUtc().difference(point.toUtc()); + if (!pointFromStart.isNegative) { // ! is Negative cus all the duration's we're calculating incidently are negative + // this message is from before we think we should be syncing with the server + // Can be because of a new server or a full resync, either way, use this (oldest message) as our lastPreSyncMessageTime + this.lastPreSyncMessagTime = point; + pointFromStart = lastPreSyncMessagTime.toUtc().difference(point.toUtc()); + } syncProgress = pointFromStart.inSeconds / range.inSeconds; notifyListeners(); }