Add mark as read on scroll functionality

Does not yet include a setting
This commit is contained in:
everhardt
2021-10-27 20:52:26 +02:00
parent 5f4409ca1f
commit 7b8bed9ac2
2 changed files with 40 additions and 0 deletions

View File

@@ -516,6 +516,24 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
@objc func scrollPositionDidChange() {
coordinator.timelineMiddleIndexPath = tableView.middleVisibleRow()
guard let firstVisibleRowIndexPath = tableView.indexPathsForVisibleRows?[0] else { return }
guard let firstVisibleArticle = dataSource.itemIdentifier(for: firstVisibleRowIndexPath) else {
return
}
guard let unreadArticlesScrolledAway = coordinator.articles.articlesAbove(article: firstVisibleArticle).unreadArticles() else { return }
coordinator.markAllAsRead(unreadArticlesScrolledAway)
for article in unreadArticlesScrolledAway {
if let indexPath = dataSource.indexPath(for: article) {
if let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell {
configure(cell, article: article)
}
}
}
}
// MARK: Reloading