From 4686a42a80210ac1bf6d642258124b904120daad Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 14 Apr 2025 11:04:32 +0200 Subject: [PATCH] Fix issue with tryPutBeforeUpdating --- LeStorage/StoredSingleton.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/LeStorage/StoredSingleton.swift b/LeStorage/StoredSingleton.swift index 459da1c..35dc82d 100644 --- a/LeStorage/StoredSingleton.swift +++ b/LeStorage/StoredSingleton.swift @@ -27,10 +27,11 @@ public class StoredSingleton: SyncedCollection { return self.items.first } - @discardableResult public func tryPutBeforeUpdating(_ instance: T) async throws -> T? { + public func tryPutBeforeUpdating(_ instance: T) async throws { let result = try await StoreCenter.main.service().rawPut(instance) - self.setItemNoSync(result) - return result + if let item = self.item() { + item.copy(from: result) + } } // MARK: - Protects from use