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
This commit is contained in:
Davide 2024-10-04 01:26:52 +02:00 committed by GitHub
parent 27b7e62376
commit edb4d127e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -135,12 +135,21 @@ extension ProfileManager {
public func remove(withIds profileIds: [Profile.ID]) async { public func remove(withIds profileIds: [Profile.ID]) async {
do { do {
// remove local profiles
var newAllProfiles = allProfiles var newAllProfiles = allProfiles
try await repository.removeEntities(withIds: profileIds) try await repository.removeEntities(withIds: profileIds)
profileIds.forEach { profileIds.forEach {
newAllProfiles.removeValue(forKey: $0) newAllProfiles.removeValue(forKey: $0)
} }
await afterRemove?(profileIds) await afterRemove?(profileIds)
// remove remote counterpart too
try? await remoteRepository?.removeEntities(withIds: profileIds)
profileIds.forEach {
allRemoteProfiles.removeValue(forKey: $0)
}
// publish update
allProfiles = newAllProfiles allProfiles = newAllProfiles
didChange.send(.remove(profileIds)) didChange.send(.remove(profileIds))
} catch { } catch {