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) } }