From 2b8723a2e3f52ffc1d45ab6f45388343af0f0734 Mon Sep 17 00:00:00 2001 From: Priyonto M Rahman Date: Mon, 23 Sep 2024 19:02:09 +0200 Subject: [PATCH] task: Unify offline alerts with Android #2150 Follows the spec from github issue. --- .../RuuviNotifierImpl/RuuviNotifierImpl+Process.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Packages/RuuviNotifier/Sources/RuuviNotifierImpl/RuuviNotifierImpl+Process.swift b/Packages/RuuviNotifier/Sources/RuuviNotifierImpl/RuuviNotifierImpl+Process.swift index 930618139..5041d7444 100644 --- a/Packages/RuuviNotifier/Sources/RuuviNotifierImpl/RuuviNotifierImpl+Process.swift +++ b/Packages/RuuviNotifier/Sources/RuuviNotifierImpl/RuuviNotifierImpl+Process.swift @@ -426,6 +426,14 @@ extension RuuviNotifierImpl { byAdding: .second, value: -Int(unseenDuration), to: Date() ) ?? Date() + // Check the last successful system sync with the cloud + if let lastSystemCloudSyncDate = localSyncState.getSyncDate() { + // If the sync date is earlier than our threshold, don't trigger the alert + if lastSystemCloudSyncDate < thresholdDateTime { + return false + } + } + // If the measurement date is earlier than our threshold, trigger the alert return record.date < thresholdDateTime }