Prevent selecting of items that may not show the current article selection as is done on the iPhone

This commit is contained in:
Maurice Parker 2019-08-29 17:49:21 -05:00
parent 3b31a4f21d
commit 86a302f787
1 changed files with 9 additions and 2 deletions

View File

@ -475,9 +475,16 @@ private extension MasterTimelineViewController {
} }
func performBlockAndRestoreSelection(_ block: (() -> Void)) { 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() 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) let indexPath = IndexPath(row: index, section: 0)
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none) tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
} }