|
|
|
|
@ -183,7 +183,7 @@ public class SyncedCollection<T : SyncedStorable>: BaseCollection<T>, SomeSynced |
|
|
|
|
// MARK: - Basic operations without sync |
|
|
|
|
|
|
|
|
|
/// Adds or update an instance without synchronizing it |
|
|
|
|
func addOrUpdateNoSync(_ instance: T) throws { |
|
|
|
|
func addOrUpdateNoSync(_ instance: T) { |
|
|
|
|
self.addOrUpdateItem(instance: instance) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -235,6 +235,20 @@ public class SyncedCollection<T : SyncedStorable>: BaseCollection<T>, SomeSynced |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: Single calls |
|
|
|
|
|
|
|
|
|
fileprivate func _addsIfPostSucceeds(_ instance: T) async throws { |
|
|
|
|
if let result = try await StoreCenter.main.service().post(instance) { |
|
|
|
|
self.addOrUpdateNoSync(result) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _updateIfPutSucceeds(_ instance: T) async throws { |
|
|
|
|
if let result = try await StoreCenter.main.service().put(instance) { |
|
|
|
|
self.addOrUpdateNoSync(result) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Sends an insert api call for the provided |
|
|
|
|
/// Calls copyFromServerInstance on the instance with the result of the HTTP call |
|
|
|
|
/// - Parameters: |
|
|
|
|
|