Skip to content

Commit

Permalink
Fix a bug in the logic for when we should update the remote address book
Browse files Browse the repository at this point in the history
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 <daira@jacaranda.org>
  • Loading branch information
daira committed Nov 19, 2024
1 parent 44303f2 commit e387638
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ directly impact users rather than highlighting other crucial architectural updat

## [Unreleased]

### Fixed
- Fixed a bug that could cause newly added address book entries not to be saved remotely.

## 1.2.3 build 3 (2024-11-19)

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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..<syncedContacts.contacts.count {
Expand Down

0 comments on commit e387638

Please # to comment.