From 19336dd07e5876de60218e43c8b5b843ed01d5ee Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 26 Nov 2019 13:01:07 -0600 Subject: [PATCH] Fix folder drops that sometimes defaulted to the account. Issue #1356 --- .../MasterFeedViewController+Drop.swift | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/iOS/MasterFeed/MasterFeedViewController+Drop.swift b/iOS/MasterFeed/MasterFeedViewController+Drop.swift index bd759e710..318157523 100644 --- a/iOS/MasterFeed/MasterFeedViewController+Drop.swift +++ b/iOS/MasterFeed/MasterFeedViewController+Drop.swift @@ -56,24 +56,18 @@ extension MasterFeedViewController: UITableViewDropDelegate { // Based on the drop we have to determine a node to start looking for a parent container. let destNode: Node? = { - if destIndexPath.row == 0 { - - return coordinator.rootNode.childAtIndex(destIndexPath.section)! - + if isFolderDrop { + return dataSource.itemIdentifier(for: destIndexPath) } else { - - if isFolderDrop { - return dataSource.itemIdentifier(for: destIndexPath) + if destIndexPath.row == 0 { + return coordinator.rootNode.childAtIndex(destIndexPath.section)! + } else if destIndexPath.row > 0 { + return dataSource.itemIdentifier(for: IndexPath(row: destIndexPath.row - 1, section: destIndexPath.section)) } else { - if destIndexPath.row > 0 { - return dataSource.itemIdentifier(for: IndexPath(row: destIndexPath.row - 1, section: destIndexPath.section)) - } else { - return nil - } + return nil } - } - + }() // Now we start looking for the parent container