Cap the possible destination index used during Feed moves
This commit is contained in:
parent
d5adbccd5b
commit
2e71cc573d
|
@ -269,7 +269,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||
if proposedDestinationIndexPath.section == 0 {
|
||||
return IndexPath(row: 0, section: 1)
|
||||
}
|
||||
return proposedDestinationIndexPath
|
||||
return coordinator.cappedIndexPath(proposedDestinationIndexPath)
|
||||
}()
|
||||
|
||||
guard let draggedNode = coordinator.nodeFor(sourceIndexPath), let destNode = coordinator.nodeFor(destIndexPath), let parentNode = destNode.parent else {
|
||||
|
|
|
@ -357,6 +357,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||
return shadowTable[section]
|
||||
}
|
||||
|
||||
func cappedIndexPath(_ indexPath: IndexPath) -> IndexPath {
|
||||
guard indexPath.section < shadowTable.count && indexPath.row < shadowTable[indexPath.section].count else {
|
||||
return IndexPath(row: shadowTable[shadowTable.count - 1].count - 1, section: shadowTable.count - 1)
|
||||
}
|
||||
return indexPath
|
||||
}
|
||||
|
||||
func indexPathFor(_ node: Node) -> IndexPath? {
|
||||
for i in 0..<shadowTable.count {
|
||||
if let row = shadowTable[i].firstIndex(of: node) {
|
||||
|
|
Loading…
Reference in New Issue