From 488fba3d9be4c13d0462faf60c313dc7305f0ff6 Mon Sep 17 00:00:00 2001 From: Paul Schmiedmayer Date: Tue, 23 Jul 2024 12:08:12 -0700 Subject: [PATCH] Avoid Setting Data when no data is provided --- .../FirestoreAccountStorage.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/SpeziFirebaseAccountStorage/FirestoreAccountStorage.swift b/Sources/SpeziFirebaseAccountStorage/FirestoreAccountStorage.swift index be8c324..852634f 100644 --- a/Sources/SpeziFirebaseAccountStorage/FirestoreAccountStorage.swift +++ b/Sources/SpeziFirebaseAccountStorage/FirestoreAccountStorage.swift @@ -90,6 +90,10 @@ public actor FirestoreAccountStorage: Module, AccountStorageConstraint { do { switch result { case let .success(data): + guard !data.isEmpty else { + return + } + try await userDocument(for: identifier.accountId) .setData(data, merge: true) case let .failure(error): @@ -137,7 +141,7 @@ public actor FirestoreAccountStorage: Module, AccountStorageConstraint { switch result { case let .success(data): try await userDocument(for: identifier.accountId) - .setData(data, merge: true) + .updateData(data) case let .failure(error): throw error }