Enable dropping onto empty accounts. Fixes #2024
This commit is contained in:
parent
5742395686
commit
93cd9dd14b
|
@ -18,12 +18,15 @@ extension MasterFeedViewController: UITableViewDropDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, dropSessionDidUpdate session: UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UITableViewDropProposal {
|
func tableView(_ tableView: UITableView, dropSessionDidUpdate session: UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UITableViewDropProposal {
|
||||||
guard let destIndexPath = destinationIndexPath,
|
guard let destIndexPath = destinationIndexPath, destIndexPath.section > 0, tableView.hasActiveDrag else {
|
||||||
destIndexPath.section > 0,
|
return UITableViewDropProposal(operation: .forbidden)
|
||||||
tableView.hasActiveDrag,
|
}
|
||||||
let destIdentifier = dataSource.itemIdentifier(for: destIndexPath),
|
|
||||||
let destAccount = destIdentifier.account,
|
guard let destIdentifier = dataSource.itemIdentifier(for: destIndexPath) else {
|
||||||
let destCell = tableView.cellForRow(at: destIndexPath) else {
|
return UITableViewDropProposal(operation: .move, intent: .insertIntoDestinationIndexPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let destAccount = destIdentifier.account, let destCell = tableView.cellForRow(at: destIndexPath) else {
|
||||||
return UITableViewDropProposal(operation: .forbidden)
|
return UITableViewDropProposal(operation: .forbidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +93,8 @@ extension MasterFeedViewController: UITableViewDropDelegate {
|
||||||
if let containerID = destIdentifier?.containerID ?? destIdentifier?.parentContainerID {
|
if let containerID = destIdentifier?.containerID ?? destIdentifier?.parentContainerID {
|
||||||
return AccountManager.shared.existingContainer(with: containerID)
|
return AccountManager.shared.existingContainer(with: containerID)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
// If we got here, we are trying to drop on an empty section header. Go and find the Account for this section
|
||||||
|
return coordinator.rootNode.childAtIndex(destIndexPath.section)?.representedObject as? Account
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue