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:
parent
27b7e62376
commit
edb4d127e9
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue