1.2.2 - "Bug fixes and improvements"
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Manages the overall data state timestamp for sync purposes. This tracks when any data in the
|
||||
/// local database was last modified, independent of individual entity timestamps.
|
||||
/// Manages the overall data state timestamp for sync purposes
|
||||
class DataStateManager {
|
||||
|
||||
private let userDefaults = UserDefaults.standard
|
||||
@@ -14,7 +13,6 @@ class DataStateManager {
|
||||
static let initialized = "openclimb_data_state_initialized"
|
||||
}
|
||||
|
||||
/// Shared instance for app-wide use
|
||||
static let shared = DataStateManager()
|
||||
|
||||
private init() {
|
||||
@@ -36,21 +34,21 @@ class DataStateManager {
|
||||
func updateDataState() {
|
||||
let now = ISO8601DateFormatter().string(from: Date())
|
||||
userDefaults.set(now, forKey: Keys.lastModified)
|
||||
print("📝 iOS Data state updated to: \(now)")
|
||||
print("iOS Data state updated to: \(now)")
|
||||
}
|
||||
|
||||
/// Gets the current data state timestamp. This represents when any data was last modified
|
||||
/// locally.
|
||||
func getLastModified() -> String {
|
||||
if let storedTimestamp = userDefaults.string(forKey: Keys.lastModified) {
|
||||
print("📅 iOS DataStateManager returning stored timestamp: \(storedTimestamp)")
|
||||
print("iOS DataStateManager returning stored timestamp: \(storedTimestamp)")
|
||||
return storedTimestamp
|
||||
}
|
||||
|
||||
// If no timestamp is stored, return epoch time to indicate very old data
|
||||
// This ensures server data will be considered newer than uninitialized local data
|
||||
let epochTime = "1970-01-01T00:00:00.000Z"
|
||||
print("⚠️ No data state timestamp found - returning epoch time: \(epochTime)")
|
||||
print("WARNING: No data state timestamp found - returning epoch time: \(epochTime)")
|
||||
return epochTime
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user