From 3db1b60b65c9154b0ce47c7af6f504e82b122bf8 Mon Sep 17 00:00:00 2001 From: everhardt Date: Wed, 27 Oct 2021 22:03:38 +0200 Subject: [PATCH] Add Mac setting for mark as read on scroll --- Mac/AppDefaults.swift | 11 ++ Mac/Base.lproj/Preferences.storyboard | 100 ++++++++++++------ .../Timeline/TimelineViewController.swift | 3 + 3 files changed, 81 insertions(+), 33 deletions(-) diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index df9b7c618..9a1ce53f0 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -33,6 +33,7 @@ final class AppDefaults { static let detailFontSize = "detailFontSize" static let openInBrowserInBackground = "openInBrowserInBackground" static let subscribeToFeedsInDefaultBrowser = "subscribeToFeedsInDefaultBrowser" + static let markArticlesAsReadOnScroll = "markArticlesAsReadOnScroll" static let articleTextSize = "articleTextSize" static let refreshInterval = "refreshInterval" static let addWebFeedAccountID = "addWebFeedAccountID" @@ -289,6 +290,16 @@ final class AppDefaults { return AppDefaults.bool(for: Key.timelineShowsSeparators) } + + var markArticlesAsReadOnScroll: Bool { + get { + return AppDefaults.bool(for: Key.markArticlesAsReadOnScroll) + } + set { + AppDefaults.setBool(for: Key.markArticlesAsReadOnScroll, newValue) + } + } + var articleTextSize: ArticleTextSize { get { let rawValue = UserDefaults.standard.integer(forKey: Key.articleTextSize) diff --git a/Mac/Base.lproj/Preferences.storyboard b/Mac/Base.lproj/Preferences.storyboard index bbe72eefa..051bc1082 100644 --- a/Mac/Base.lproj/Preferences.storyboard +++ b/Mac/Base.lproj/Preferences.storyboard @@ -1,8 +1,8 @@ - + - + @@ -31,23 +31,31 @@ - - + + - + - + + + + + + + + + - + @@ -76,7 +84,7 @@ - + @@ -91,7 +99,7 @@ - + - + @@ -112,7 +120,7 @@ - + @@ -127,7 +135,7 @@ - + @@ -155,10 +163,10 @@ - + - + @@ -166,7 +174,7 @@ - + @@ -201,7 +209,7 @@ - + @@ -209,7 +217,7 @@ - + + @@ -251,11 +279,14 @@ + + - + + @@ -268,6 +299,7 @@ + @@ -282,6 +314,8 @@ + + @@ -307,7 +341,7 @@ - + @@ -487,16 +521,16 @@ - + - + - + - + @@ -603,7 +637,7 @@ - + @@ -658,16 +692,16 @@ - + - + - + - + @@ -770,7 +804,7 @@ - + diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index d29c91a8d..58a792900 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -337,6 +337,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } @objc func scrollPositionDidChange(){ + if !AppDefaults.shared.markArticlesAsReadOnScroll { + return + } let firstVisibleRowIndex = tableView.rows(in: tableView.visibleRect).location guard let unreadArticlesScrolledAway = articles.articlesAbove(position: firstVisibleRowIndex).unreadArticles() else { return }