mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge branch 'mark-as-read-on-scroll' into super-cut
This commit is contained in:
@@ -35,7 +35,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
|
||||
weak var coordinator: SceneCoordinator!
|
||||
var undoableCommands = [UndoableCommand]()
|
||||
let scrollPositionQueue = CoalescingQueue(name: "Timeline Scroll Position", interval: 0.3, maxInterval: 1.0)
|
||||
|
||||
private let keyboardManager = KeyboardManager(type: .timeline)
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
@@ -434,7 +433,25 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
}
|
||||
|
||||
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
scrollPositionQueue.add(self, #selector(scrollPositionDidChange))
|
||||
coordinator.timelineMiddleIndexPath = tableView.middleVisibleRow()
|
||||
|
||||
// Implement Mark As Read on Scroll where we mark after the leading edge goes a little beyond the safe area inset
|
||||
guard AppDefaults.shared.markArticlesAsReadOnScroll,
|
||||
let firstVisibleindexPath = tableView.indexPathsForVisibleRows?.first else { return }
|
||||
|
||||
var articles = [Article]()
|
||||
for i in firstVisibleindexPath.row..<tableView.numberOfRows(inSection: firstVisibleindexPath.section) {
|
||||
let indexPath = IndexPath(row: i, section: firstVisibleindexPath.section)
|
||||
let cellRect = tableView.rectForRow(at: indexPath)
|
||||
|
||||
guard tableView.convert(cellRect, to: nil).origin.y < tableView.safeAreaInsets.top - 40 else { break }
|
||||
|
||||
if let article = dataSource.itemIdentifier(for: indexPath), article.status.read == false {
|
||||
articles.append(article)
|
||||
}
|
||||
}
|
||||
|
||||
coordinator.markAllAsRead(articles)
|
||||
}
|
||||
|
||||
// MARK: Notifications
|
||||
@@ -530,10 +547,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
updateUI()
|
||||
}
|
||||
|
||||
@objc func scrollPositionDidChange() {
|
||||
coordinator.timelineMiddleIndexPath = tableView.middleVisibleRow()
|
||||
}
|
||||
|
||||
// MARK: Reloading
|
||||
|
||||
func queueReloadAvailableCells() {
|
||||
@@ -723,7 +736,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