Make arrow key scrolling work like it does on the Mac timeline
This commit is contained in:
parent
c8b5b10edd
commit
a6f6462afd
|
@ -97,8 +97,10 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||
node = coordinator.rootNode.descendantNodeRepresentingObject(representedObject as AnyObject)
|
||||
}
|
||||
|
||||
if let node = node, coordinator.indexPathFor(node) != nil {
|
||||
reloadNode(node)
|
||||
if let node = node, let indexPath = coordinator.indexPathFor(node), let unreadCountProvider = node.representedObject as? UnreadCountProvider {
|
||||
if let cell = tableView.cellForRow(at: indexPath) as? MasterFeedTableViewCell {
|
||||
cell.unreadCount = unreadCountProvider.unreadCount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,7 +439,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||
}
|
||||
if let indexPath = coordinator.currentFeedIndexPath {
|
||||
if tableView.indexPathForSelectedRow != indexPath {
|
||||
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .middle)
|
||||
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: true)
|
||||
}
|
||||
} else {
|
||||
tableView.selectRow(at: nil, animated: true, scrollPosition: .none)
|
||||
|
@ -667,7 +669,7 @@ private extension MasterFeedViewController {
|
|||
return
|
||||
}
|
||||
if let indexPath = coordinator.masterFeedIndexPathForCurrentTimeline(), indexPath != tableView.indexPathForSelectedRow {
|
||||
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
|
||||
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
|
||||
if let indexPath = coordinator.currentArticleIndexPath {
|
||||
if tableView.indexPathForSelectedRow != indexPath {
|
||||
tableView.selectRow(at: indexPath, animated: animate, scrollPosition: .middle)
|
||||
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: true)
|
||||
}
|
||||
} else {
|
||||
tableView.selectRow(at: nil, animated: animate, scrollPosition: .none)
|
||||
|
@ -307,10 +307,20 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
}
|
||||
|
||||
@objc func statusesDidChange(_ note: Notification) {
|
||||
guard let articles = note.userInfo?[Account.UserInfoKey.articles] as? Set<Article> else {
|
||||
guard let updatedArticles = note.userInfo?[Account.UserInfoKey.articles] as? Set<Article> else {
|
||||
return
|
||||
}
|
||||
reloadVisibleCells(for: articles)
|
||||
|
||||
let visibleArticles = tableView.indexPathsForVisibleRows!.map { return coordinator.articles[$0.row] }
|
||||
let visibleUpdatedArticles = visibleArticles.filter { updatedArticles.contains($0) }
|
||||
|
||||
for article in visibleUpdatedArticles {
|
||||
if let articleIndex = coordinator.indexForArticleID(article.articleID) {
|
||||
if let cell = tableView.cellForRow(at: IndexPath(row: articleIndex, section: 0)) as? MasterTimelineTableViewCell {
|
||||
configure(cell, article: article)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func feedIconDidBecomeAvailable(_ note: Notification) {
|
||||
|
@ -381,33 +391,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
reloadCells(visibleArticles)
|
||||
}
|
||||
|
||||
private func reloadVisibleCells(for articles: [Article]) {
|
||||
reloadVisibleCells(for: Set(articles.articleIDs()))
|
||||
}
|
||||
|
||||
private func reloadVisibleCells(for articles: Set<Article>) {
|
||||
reloadVisibleCells(for: articles.articleIDs())
|
||||
}
|
||||
|
||||
private func reloadVisibleCells(for articleIDs: Set<String>) {
|
||||
if articleIDs.isEmpty {
|
||||
return
|
||||
}
|
||||
let indexes = coordinator.indexesForArticleIDs(articleIDs)
|
||||
reloadVisibleCells(for: indexes)
|
||||
}
|
||||
|
||||
private func reloadVisibleCells(for indexes: IndexSet) {
|
||||
let reloadArticles: [Article] = tableView.indexPathsForVisibleRows!.compactMap { indexPath in
|
||||
if indexes.contains(indexPath.row) {
|
||||
return coordinator.articles[indexPath.row]
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
reloadCells(reloadArticles)
|
||||
}
|
||||
|
||||
private func reloadCells(_ articles: [Article]) {
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reloadItems(articles)
|
||||
|
@ -560,7 +543,7 @@ private extension MasterTimelineViewController {
|
|||
}
|
||||
if let articleID = coordinator.currentArticle?.articleID, let index = coordinator.indexForArticleID(articleID) {
|
||||
let indexPath = IndexPath(row: index, section: 0)
|
||||
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
|
||||
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -579,6 +579,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||
selectArticle(nil)
|
||||
currentFeedIndexPath = indexPath
|
||||
|
||||
masterFeedViewController.updateFeedSelection()
|
||||
|
||||
if let ip = indexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher {
|
||||
timelineFetcher = fetcher
|
||||
updateSelectingActivity(with: node)
|
||||
|
@ -596,7 +598,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||
}
|
||||
}
|
||||
|
||||
masterFeedViewController.updateFeedSelection()
|
||||
}
|
||||
|
||||
func selectPrevFeed() {
|
||||
|
@ -633,10 +634,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||
currentArticleIndexPath = indexPath
|
||||
activityManager.reading(currentArticle)
|
||||
|
||||
if let article = currentArticle {
|
||||
markArticles(Set([article]), statusKey: .read, flag: true)
|
||||
}
|
||||
|
||||
if indexPath == nil {
|
||||
if rootSplitViewController.isCollapsed {
|
||||
if masterNavigationController.children.last is DetailViewController {
|
||||
|
@ -670,6 +667,9 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||
|
||||
detailViewController?.updateArticleSelection()
|
||||
|
||||
if let article = currentArticle {
|
||||
markArticles(Set([article]), statusKey: .read, flag: true)
|
||||
}
|
||||
}
|
||||
|
||||
func beginSearching() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 50cf102acd0592ec3bff2446f19386b6593e1ff8
|
||||
Subproject commit 75b609926fe64c7c14428a39bda1f301cd968f46
|
Loading…
Reference in New Issue