From edb4d127e9c692e9a82f6e1a351dffad7869ae2b Mon Sep 17 00:00:00 2001 From: Davide Date: Fri, 4 Oct 2024 01:26:52 +0200 Subject: [PATCH] Delete remote profiles on local removal (#677) Remote profiles were never deleted. Now, when removing a profile: - The profile is deleted from the local store - The profile is deleted from the remote store - Other synced devices receive the update and delete the profile from their remote store - However, they retain a local copy of the profile - The copy doesn't appear as "Shared on iCloud" anymore --- .../Sources/AppLibrary/Business/ProfileManager.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Passepartout/Library/Sources/AppLibrary/Business/ProfileManager.swift b/Passepartout/Library/Sources/AppLibrary/Business/ProfileManager.swift index d59964cf..8575b02a 100644 --- a/Passepartout/Library/Sources/AppLibrary/Business/ProfileManager.swift +++ b/Passepartout/Library/Sources/AppLibrary/Business/ProfileManager.swift @@ -135,12 +135,21 @@ extension ProfileManager { public func remove(withIds profileIds: [Profile.ID]) async { do { + // remove local profiles var newAllProfiles = allProfiles try await repository.removeEntities(withIds: profileIds) profileIds.forEach { newAllProfiles.removeValue(forKey: $0) } await afterRemove?(profileIds) + + // remove remote counterpart too + try? await remoteRepository?.removeEntities(withIds: profileIds) + profileIds.forEach { + allRemoteProfiles.removeValue(forKey: $0) + } + + // publish update allProfiles = newAllProfiles didChange.send(.remove(profileIds)) } catch {