From 23b8af46349f2108562006ad3c790fa7875729a2 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 24 Feb 2020 08:07:14 -0800 Subject: [PATCH] Don't end the operation until the deselection animation has completed. (Regression) --- iOS/MasterFeed/UpdateSelectionOperation.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/iOS/MasterFeed/UpdateSelectionOperation.swift b/iOS/MasterFeed/UpdateSelectionOperation.swift index 7a4820586..287e093db 100644 --- a/iOS/MasterFeed/UpdateSelectionOperation.swift +++ b/iOS/MasterFeed/UpdateSelectionOperation.swift @@ -40,8 +40,17 @@ class UpdateSelectionOperation: MainThreadOperation { tableView.selectRowAndScrollIfNotVisible(at: indexPath, animations: animations) CATransaction.commit() } else { - tableView.selectRow(at: nil, animated: animations.contains(.select), scrollPosition: .none) - self.operationDelegate?.operationDidComplete(self) + if animations.contains(.select) { + CATransaction.begin() + CATransaction.setCompletionBlock { + 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) + } } } else { self.operationDelegate?.operationDidComplete(self)