From 023b58e8c1228122a2d19cd8ec4f2bdf69322795 Mon Sep 17 00:00:00 2001 From: everhardt Date: Thu, 25 Nov 2021 21:09:17 +0100 Subject: [PATCH] feat: Improved marking as read on scroll on macOS register top visible article when scrolling starts and ignore the ones above that --- Mac/MainWindow/Timeline/TimelineViewController.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index 02e057597..ff5f4cb32 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -141,6 +141,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr var undoableCommands = [UndoableCommand]() var articlesWithManuallyChangedReadStatus: Set
= Set() + private var firstVisibleRowIndexWhenDraggingBegan: Int = 0 private var isScrolling = false @@ -352,6 +353,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr @objc func scrollViewWillStartLiveScroll(notification: Notification){ isScrolling = true + firstVisibleRowIndexWhenDraggingBegan = tableView.rows(in: tableView.visibleRect).location } @objc func scrollViewDidEndLiveScroll(notification: Notification){ @@ -365,7 +367,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr // Mark articles scrolled out of sight at the top as read let firstVisibleRowIndex = tableView.rows(in: tableView.visibleRect).location - let unreadArticlesScrolledAway = articles.articlesAbove(position: firstVisibleRowIndex).filter { !$0.status.read && !articlesWithManuallyChangedReadStatus.contains($0) } + + let unreadArticlesScrolledAway = articles.articlesBetween( + upperPosition: firstVisibleRowIndexWhenDraggingBegan, lowerPosition: firstVisibleRowIndex).filter { !$0.status.read && !articlesWithManuallyChangedReadStatus.contains($0) } if unreadArticlesScrolledAway.isEmpty { return }