|
|
|
|
@ -59,6 +59,11 @@ extension StoredCollection: SomeSyncedCollection where T : SyncedStorable { |
|
|
|
|
/// to an object when it's inserted. The StoredCollection possibly needs to update its own copy with new values. |
|
|
|
|
/// - serverInstance: the instance of the object on the server |
|
|
|
|
func updateFromServerInstance(_ serverInstance: T) { |
|
|
|
|
|
|
|
|
|
guard T.copyServerResponse else { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DispatchQueue.main.async { |
|
|
|
|
if let localInstance = self.findById(serverInstance.id) { |
|
|
|
|
localInstance.copy(from: serverInstance) |
|
|
|
|
@ -104,7 +109,7 @@ extension StoredCollection: SomeSyncedCollection where T : SyncedStorable { |
|
|
|
|
|
|
|
|
|
/// Adds or update an instance and writes |
|
|
|
|
public func addOrUpdate(instance: T) { |
|
|
|
|
Logger.log("\(T.resourceName()) : one item") |
|
|
|
|
// Logger.log("\(T.resourceName()) : one item") |
|
|
|
|
defer { |
|
|
|
|
self.setChanged() |
|
|
|
|
} |
|
|
|
|
@ -121,7 +126,7 @@ extension StoredCollection: SomeSyncedCollection where T : SyncedStorable { |
|
|
|
|
|
|
|
|
|
/// Adds or update a sequence and writes |
|
|
|
|
public func addOrUpdate(contentOfs sequence: any Sequence<T>) { |
|
|
|
|
Logger.log("\(T.resourceName()) : \(sequence.underestimatedCount) items") |
|
|
|
|
// Logger.log("\(T.resourceName()) : \(sequence.underestimatedCount) items") |
|
|
|
|
defer { |
|
|
|
|
self.setChanged() |
|
|
|
|
} |
|
|
|
|
|