From ab8e0d04d7118a139710e5945039f647d760e497 Mon Sep 17 00:00:00 2001 From: Daira-Emma Hopwood Date: Tue, 19 Nov 2024 15:01:20 +0000 Subject: [PATCH] Fix a bug in the logic for when we should update the remote address book file. This would have caused new address book entries not to be written (after the first remote store of the file). Signed-off-by: Daira-Emma Hopwood --- .../AddressBookClient/AddressBookLiveKey.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/Sources/Dependencies/AddressBookClient/AddressBookLiveKey.swift b/modules/Sources/Dependencies/AddressBookClient/AddressBookLiveKey.swift index 31a2fb3e4..205ed29a6 100644 --- a/modules/Sources/Dependencies/AddressBookClient/AddressBookLiveKey.swift +++ b/modules/Sources/Dependencies/AddressBookClient/AddressBookLiveKey.swift @@ -165,7 +165,7 @@ extension AddressBookClient: DependencyKey { remoteStorage: RemoteStorageClient, storeAfterSync: Bool = true ) throws -> (contacts: AddressBookContacts, remoteStoreResult: RemoteStoreResult) { - // Ensure remote contacts are prepared + // Ensure remote contacts are prepared. var remoteContacts: AddressBookContacts = .empty var shouldUpdateRemote = false var cannotUpdateRemote = false @@ -185,14 +185,16 @@ extension AddressBookClient: DependencyKey { throw error } - // Merge strategy + // We merge from the local contacts into the remote contacts, which + // makes it easy to see when the merged contacts have changed relative + // to the previous remote contacts. var syncedContacts = AddressBookContacts( lastUpdated: Date(), version: AddressBookContacts.Constants.version, - contacts: contacts.contacts + contacts: remoteContacts.contacts ) - remoteContacts.contacts.forEach { + contacts.contacts.forEach { var notFound = true for i in 0..