Clear profile selection if current profile removed
Do it before ForEach rearranges NavigationLink elements, because it may trigger undesired navigation to a deleted profile. Restore related assertion.
This commit is contained in:
parent
7128352a9c
commit
18e9f7cbb5
|
@ -160,11 +160,23 @@ extension OrganizerView.ProfilesList {
|
|||
}
|
||||
|
||||
private func removeProfiles(_ indexSet: IndexSet) {
|
||||
withAnimation {
|
||||
doRemoveProfiles(indexSet)
|
||||
}
|
||||
}
|
||||
|
||||
private func doRemoveProfiles(_ indexSet: IndexSet) {
|
||||
let headers = profileManager.headers.sorted()
|
||||
var toDelete: [UUID] = []
|
||||
indexSet.forEach {
|
||||
toDelete.append(headers[$0].id)
|
||||
}
|
||||
|
||||
// clear selection before removal to avoid triggering a bogus navigation push
|
||||
if let selectedProfileId = selectedProfileId, toDelete.contains(selectedProfileId) {
|
||||
self.selectedProfileId = nil
|
||||
}
|
||||
|
||||
profileManager.removeProfiles(withIds: toDelete)
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ extension ProfileManager {
|
|||
}
|
||||
|
||||
guard let profile = strategy.profile(withId: id) else {
|
||||
// assertionFailure("Profile in headers yet not found in persistent store")
|
||||
assertionFailure("Profile in headers yet not found in persistent store")
|
||||
return nil
|
||||
}
|
||||
guard availabilityFilter?(profile.header) ?? true else {
|
||||
|
|
Loading…
Reference in New Issue