From c8b5b10edd008781f49555584836e8938b854198 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 6 Sep 2019 11:22:35 -0500 Subject: [PATCH] Check if the split is collapsed to see if we are maintaining the selection --- iOS/MasterFeed/MasterFeedViewController.swift | 8 +++++--- iOS/MasterTimeline/MasterTimelineViewController.swift | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index e42359002..13feab1bb 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -432,7 +432,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { // MARK: API func updateFeedSelection() { - guard traitCollection.userInterfaceIdiom == .pad else { + guard !coordinator.isRootSplitCollapsed else { return } if let indexPath = coordinator.currentFeedIndexPath { @@ -628,7 +628,9 @@ private extension MasterFeedViewController { private func reloadCells(_ nodes: [Node]) { var snapshot = dataSource.snapshot() snapshot.reloadItems(nodes) - dataSource.apply(snapshot, animatingDifferences: false) + dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in + self?.restoreSelectionIfNecessary() + } } private func accountForNode(_ node: Node) -> Account? { @@ -661,7 +663,7 @@ private extension MasterFeedViewController { } func restoreSelectionIfNecessary() { - guard traitCollection.userInterfaceIdiom == .pad else { + guard !coordinator.isRootSplitCollapsed else { return } if let indexPath = coordinator.masterFeedIndexPathForCurrentTimeline(), indexPath != tableView.indexPathForSelectedRow { diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index d9b6b9353..a612490e6 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -156,7 +156,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner } func updateArticleSelection(animate: Bool) { - guard traitCollection.userInterfaceIdiom == .pad && !coordinator.articles.isEmpty else { + guard !coordinator.isRootSplitCollapsed && !coordinator.articles.isEmpty else { return } @@ -555,7 +555,7 @@ private extension MasterTimelineViewController { } func restoreSelectionIfNecessary() { - guard traitCollection.userInterfaceIdiom == .pad else { + guard !coordinator.isRootSplitCollapsed else { return } if let articleID = coordinator.currentArticle?.articleID, let index = coordinator.indexForArticleID(articleID) {