From 86a302f78753a3f60660cc95f264ef315f88ee37 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 29 Aug 2019 17:49:21 -0500 Subject: [PATCH] Prevent selecting of items that may not show the current article selection as is done on the iPhone --- iOS/MasterTimeline/MasterTimelineViewController.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index e4715c2a4..b1df0488c 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -475,9 +475,16 @@ private extension MasterTimelineViewController { } func performBlockAndRestoreSelection(_ block: (() -> Void)) { - let article = coordinator.currentArticle + let articleID: String? = { + if let indexPath = tableView.indexPathForSelectedRow, indexPath.row < coordinator.articles.count { + return coordinator.articles[indexPath.row].articleID + } + return nil + }() + block() - if let articleID = article?.articleID, let index = coordinator.indexesForArticleIDs(Set([articleID])).first { + + if let articleID = articleID, let index = coordinator.indexesForArticleIDs(Set([articleID])).first { let indexPath = IndexPath(row: index, section: 0) tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none) }