Do not mark articles as read on scroll when they were manually toggled

This commit is contained in:
everhardt
2021-10-30 10:37:10 +02:00
parent 8bce42df56
commit 3b6a3cf4e7
4 changed files with 28 additions and 2 deletions

View File

@@ -111,6 +111,9 @@ private extension TimelineViewController {
func markArticles(_ articles: [Article], read: Bool) {
markArticles(articles, statusKey: .read, flag: read)
for article in articles {
articlesWithManuallyChangedReadStatus.insert(article)
}
}
func markArticles(_ articles: [Article], starred: Bool) {

View File

@@ -138,6 +138,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
}
var undoableCommands = [UndoableCommand]()
var articlesWithManuallyChangedReadStatus: Set<Article> = Set()
private var fetchSerialNumber = 0
private let fetchRequestQueue = FetchRequestQueue()
private var exceptionArticleFetcher: ArticleFetcher?
@@ -341,7 +344,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
return
}
let firstVisibleRowIndex = tableView.rows(in: tableView.visibleRect).location
guard let unreadArticlesScrolledAway = articles.articlesAbove(position: firstVisibleRowIndex).unreadArticles() else { return }
let unreadArticlesScrolledAway = articles.articlesAbove(position: firstVisibleRowIndex).filter { !$0.status.read && !articlesWithManuallyChangedReadStatus.contains($0) }
if unreadArticlesScrolledAway.isEmpty { return }
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: unreadArticlesScrolledAway, markingRead: true, undoManager: undoManager) else {
return
@@ -370,6 +375,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
return
}
runCommand(markReadCommand)
for article in selectedArticles {
articlesWithManuallyChangedReadStatus.insert(article)
}
}
@IBAction func markSelectedArticlesAsUnread(_ sender: Any?) {
@@ -377,6 +385,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
return
}
runCommand(markUnreadCommand)
for article in selectedArticles {
articlesWithManuallyChangedReadStatus.insert(article)
}
}
@IBAction func copy(_ sender: Any?) {
@@ -928,6 +939,7 @@ extension TimelineViewController: NSTableViewDelegate {
return
}
self.runCommand(markUnreadCommand)
articlesWithManuallyChangedReadStatus.insert(article)
}
private func toggleArticleStarred(_ article: Article) {