Fix bug where dragging a feed onto an empty account failed. Issue #1255

This commit is contained in:
Maurice Parker 2019-11-05 07:12:51 -06:00
parent 69c3d218b9
commit d4f9e73438
1 changed files with 6 additions and 1 deletions

View File

@ -294,11 +294,16 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
return coordinator.cappedIndexPath(proposedDestinationIndexPath) return coordinator.cappedIndexPath(proposedDestinationIndexPath)
}() }()
guard let draggedNode = dataSource.itemIdentifier(for: sourceIndexPath), let destNode = dataSource.itemIdentifier(for: destIndexPath), let parentNode = destNode.parent else { guard let draggedNode = dataSource.itemIdentifier(for: sourceIndexPath) else {
assertionFailure("This should never happen") assertionFailure("This should never happen")
return sourceIndexPath return sourceIndexPath
} }
// If there is no destination node, we are dragging onto an empty Account
guard let destNode = dataSource.itemIdentifier(for: destIndexPath), let parentNode = destNode.parent else {
return proposedDestinationIndexPath
}
// If this is a folder and isn't expanded or doesn't have any entries, let the users drop on it // If this is a folder and isn't expanded or doesn't have any entries, let the users drop on it
if destNode.representedObject is Folder && (destNode.numberOfChildNodes == 0 || !destNode.isExpanded) { if destNode.representedObject is Folder && (destNode.numberOfChildNodes == 0 || !destNode.isExpanded) {
let movementAdjustment = sourceIndexPath > destIndexPath ? 1 : 0 let movementAdjustment = sourceIndexPath > destIndexPath ? 1 : 0