From 5c69fa2d62240a114f8f267b852f1d6708ef9a6c Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Sat, 9 Apr 2022 16:42:40 -0400 Subject: [PATCH] Logs to debug syncing logic. --- Clocker/Overall App/DataStore.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Clocker/Overall App/DataStore.swift b/Clocker/Overall App/DataStore.swift index 3c24632..e837bff 100644 --- a/Clocker/Overall App/DataStore.swift +++ b/Clocker/Overall App/DataStore.swift @@ -71,13 +71,22 @@ class DataStore: NSObject { let cloudTimezones = ubiquitousStore?.object(forKey: CLDefaultPreferenceKey) as? [Data] let cloudLastUpdateDate = (ubiquitousStore?.object(forKey: CLUbiquitousStoreLastUpdateKey) as? Date) ?? Date() let defaultsLastUpdateDate = (ubiquitousStore?.object(forKey: CLUserDefaultsLastUpdateKey) as? Date) ?? Date() + + if cloudTimezones == currentTimezones { + Logger.info("Ubiquitous Store timezones aren't equal to current timezones") + } + + if defaultsLastUpdateDate.isLaterThanOrEqual(to: cloudLastUpdateDate) { + Logger.info("Ubiquitous Store is stale as compared to User Defaults") + } if cloudTimezones != currentTimezones, cloudLastUpdateDate.isLaterThanOrEqual(to: defaultsLastUpdateDate) { - Logger.info("Syncing local timezones with data from the ☁️") + Logger.info("Syncing local timezones with data from the ☁️. ☁️ last update timestamp is recent") userDefaults.set(cloudTimezones, forKey: CLDefaultPreferenceKey) userDefaults.set(Date(), forKey: CLUserDefaultsLastUpdateKey) NotificationCenter.default.post(name: DataStore.didSyncFromExternalSourceNotification, object: self) + return } }