mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge branch 'feat-1844-pull-up-mark-as-read' of https://github.com/everhardt/NetNewsWire into everhardt-feat-1844-pull-up-mark-as-read
This commit is contained in:
@@ -37,6 +37,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
var undoableCommands = [UndoableCommand]()
|
||||
let scrollPositionQueue = CoalescingQueue(name: "Timeline Scroll Position", interval: 0.3, maxInterval: 1.0)
|
||||
|
||||
private var firstVisibleArticleWhenDraggingBegan: Article?
|
||||
|
||||
private let keyboardManager = KeyboardManager(type: .timeline)
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
|
||||
@@ -433,8 +435,21 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
coordinator.selectArticle(article, animations: [.scroll, .select, .navigation])
|
||||
}
|
||||
|
||||
override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
guard let visibleRowIndexPaths = tableView.indexPathsForVisibleRows, visibleRowIndexPaths.count > 0 else { return }
|
||||
let firstVisibleRowIndexPath = visibleRowIndexPaths[0]
|
||||
|
||||
if scrollView.isTracking {
|
||||
firstVisibleArticleWhenDraggingBegan = dataSource.itemIdentifier(for: firstVisibleRowIndexPath)
|
||||
} else {
|
||||
firstVisibleArticleWhenDraggingBegan = nil
|
||||
}
|
||||
}
|
||||
|
||||
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
scrollPositionQueue.add(self, #selector(scrollPositionDidChange))
|
||||
if scrollView.isTracking {
|
||||
scrollPositionQueue.add(self, #selector(scrollPositionDidChange))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Notifications
|
||||
@@ -532,6 +547,33 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
|
||||
@objc func scrollPositionDidChange() {
|
||||
coordinator.timelineMiddleIndexPath = tableView.middleVisibleRow()
|
||||
|
||||
if !AppDefaults.shared.markArticlesAsReadOnScroll {
|
||||
return
|
||||
}
|
||||
|
||||
// Mark articles scrolled out of sight at the top as read
|
||||
guard let visibleRowIndexPaths = tableView.indexPathsForVisibleRows, visibleRowIndexPaths.count > 0 else { return }
|
||||
let firstVisibleRowIndexPath = visibleRowIndexPaths[0]
|
||||
|
||||
guard let firstVisibleArticle = dataSource.itemIdentifier(for: firstVisibleRowIndexPath), let firstArticleScrolledAway = firstVisibleArticleWhenDraggingBegan else {
|
||||
return
|
||||
}
|
||||
|
||||
guard let unreadArticlesScrolledAway = coordinator.articles
|
||||
.articlesBetween(upperArticle: firstArticleScrolledAway, lowerArticle: firstVisibleArticle)
|
||||
.filter({ !coordinator.directlyMarkedAsUnreadArticles.contains($0) })
|
||||
.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, indexPath: indexPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Reloading
|
||||
@@ -723,7 +765,6 @@ private extension MasterTimelineViewController {
|
||||
}
|
||||
|
||||
func configure(_ cell: MasterTimelineTableViewCell, article: Article, indexPath: IndexPath) {
|
||||
|
||||
let iconImage = iconImageFor(article)
|
||||
let featuredImage = featuredImageFor(article)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user