From 8cffd206ecd24362e249cb26c6aceb787f4facbe Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 22 Oct 2020 19:48:09 -0500 Subject: [PATCH] Change to use deselect instead of selecting a nil indexPath since deselect still animates correctly on iOS 14. --- iOS/MasterFeed/UpdateSelectionOperation.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/iOS/MasterFeed/UpdateSelectionOperation.swift b/iOS/MasterFeed/UpdateSelectionOperation.swift index 287e093db..1660ed1e9 100644 --- a/iOS/MasterFeed/UpdateSelectionOperation.swift +++ b/iOS/MasterFeed/UpdateSelectionOperation.swift @@ -40,15 +40,19 @@ class UpdateSelectionOperation: MainThreadOperation { tableView.selectRowAndScrollIfNotVisible(at: indexPath, animations: animations) CATransaction.commit() } else { - if animations.contains(.select) { - CATransaction.begin() - CATransaction.setCompletionBlock { + if let indexPath = tableView.indexPathForSelectedRow { + if animations.contains(.select) { + CATransaction.begin() + CATransaction.setCompletionBlock { + self.operationDelegate?.operationDidComplete(self) + } + tableView.deselectRow(at: indexPath, animated: true) + CATransaction.commit() + } else { + tableView.deselectRow(at: indexPath, animated: false) self.operationDelegate?.operationDidComplete(self) } - tableView.selectRow(at: nil, animated: true, scrollPosition: .none) - CATransaction.commit() } else { - tableView.selectRow(at: nil, animated: false, scrollPosition: .none) self.operationDelegate?.operationDidComplete(self) } }