From 0a83bddaf623e5e772b97e435af43f7124d30041 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 28 May 2025 17:19:26 +0200 Subject: [PATCH] Rename shared property of Synced objects --- LeStorage/ApiCallCollection.swift | 1 + LeStorage/ModelObject.swift | 6 +++--- LeStorage/StoreCenter.swift | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/LeStorage/ApiCallCollection.swift b/LeStorage/ApiCallCollection.swift index ca51a31..afe796e 100644 --- a/LeStorage/ApiCallCollection.swift +++ b/LeStorage/ApiCallCollection.swift @@ -251,6 +251,7 @@ actor ApiCallCollection: SomeCallCollection { @discardableResult func _executeGetCall(apiCall: ApiCall) async throws -> Data { let data = try await self.storeCenter.executeGet(apiCall: apiCall) + Logger.log("GET received = \(T.resourceName())") if T.self == GetSyncData.self { let syncData = try SyncData(data: data, storeCenter: self.storeCenter) diff --git a/LeStorage/ModelObject.swift b/LeStorage/ModelObject.swift index 4410d54..dad1e78 100644 --- a/LeStorage/ModelObject.swift +++ b/LeStorage/ModelObject.swift @@ -65,7 +65,7 @@ open class SyncedModelObject: BaseModelObject { enum CodingKeys: String, CodingKey { case relatedUser case lastUpdate - case shared = "_shared" + case sharing = "_sharing" } // Required initializer for Decodable @@ -73,7 +73,7 @@ open class SyncedModelObject: BaseModelObject { let container = try decoder.container(keyedBy: CodingKeys.self) self.relatedUser = try container.decodeIfPresent(String.self, forKey: .relatedUser) self.lastUpdate = try container.decodeIfPresent(Date.self, forKey: .lastUpdate) ?? Date() - self.sharing = try container.decodeIfPresent(SharingStatus.self, forKey: .shared) + self.sharing = try container.decodeIfPresent(SharingStatus.self, forKey: .sharing) try super.init(from: decoder) } @@ -84,7 +84,7 @@ open class SyncedModelObject: BaseModelObject { try container.encode(relatedUser, forKey: .relatedUser) try container.encode(lastUpdate, forKey: .lastUpdate) if self.sharing != nil { - try container.encodeIfPresent(sharing, forKey: .shared) + try container.encodeIfPresent(sharing, forKey: .sharing) } try super.encode(to: encoder) diff --git a/LeStorage/StoreCenter.swift b/LeStorage/StoreCenter.swift index 2c3c9cc..9ae0c6c 100644 --- a/LeStorage/StoreCenter.swift +++ b/LeStorage/StoreCenter.swift @@ -615,7 +615,8 @@ public class StoreCenter { } let lastSync = self._settingsStorage.item.lastSynchronization - + Logger.log("REQUEST sync: \(lastSync)") + let syncGetCollection: ApiCallCollection = try self.apiCallCollection() if await syncGetCollection.hasPendingCalls() { await syncGetCollection.rescheduleImmediately()