Change so that the tree controller can't be rebuilt before all async deletes have completed. Issue #1002

This commit is contained in:
Maurice Parker 2020-02-26 17:28:52 -08:00
parent 66ce3db1fc
commit 7c060bb068

View File

@ -44,26 +44,21 @@ final class DeleteCommand: UndoableCommand {
} }
func perform() { func perform() {
perform {}
BatchUpdate.shared.perform {
itemSpecifiers.forEach { $0.delete() {} }
treeController.rebuild()
}
registerUndo()
} }
func perform(completion: @escaping () -> Void) { func perform(completion: @escaping () -> Void) {
let group = DispatchGroup() let group = DispatchGroup()
group.enter()
itemSpecifiers.forEach { itemSpecifiers.forEach {
group.enter()
$0.delete() { $0.delete() {
group.leave() group.leave()
} }
} }
treeController.rebuild()
group.notify(queue: DispatchQueue.main) { group.notify(queue: DispatchQueue.main) {
self.treeController.rebuild()
self.registerUndo() self.registerUndo()
completion() completion()
} }