mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-23 08:09:41 +01:00
Do not mark articles as read on scroll when they were manually toggled
This commit is contained in:
parent
8bce42df56
commit
3b6a3cf4e7
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -527,7 +527,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
return
|
||||
}
|
||||
|
||||
guard let unreadArticlesScrolledAway = coordinator.articles.articlesAbove(article: firstVisibleArticle).unreadArticles() else { return }
|
||||
guard let unreadArticlesScrolledAway = coordinator.articles
|
||||
.articlesAbove(article: firstVisibleArticle)
|
||||
.filter({ !coordinator.articlesWithManuallyChangedReadStatus.contains($0) })
|
||||
.unreadArticles() else { return }
|
||||
|
||||
coordinator.markAllAsRead(unreadArticlesScrolledAway)
|
||||
|
||||
|
@ -182,6 +182,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
private(set) var showFeedNames = ShowFeedName.none
|
||||
private(set) var showIcons = false
|
||||
|
||||
var articlesWithManuallyChangedReadStatus: Set<Article> = Set()
|
||||
|
||||
var prevFeedIndexPath: IndexPath? {
|
||||
guard let indexPath = currentFeedIndexPath else {
|
||||
return nil
|
||||
@ -783,6 +785,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
return
|
||||
}
|
||||
|
||||
articlesWithManuallyChangedReadStatus.removeAll()
|
||||
|
||||
currentFeedIndexPath = indexPath
|
||||
masterFeedViewController.updateFeedSelection(animations: animations)
|
||||
|
||||
@ -1073,24 +1077,28 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
func markAsReadForCurrentArticle() {
|
||||
if let article = currentArticle {
|
||||
markArticlesWithUndo([article], statusKey: .read, flag: true)
|
||||
articlesWithManuallyChangedReadStatus.insert(article)
|
||||
}
|
||||
}
|
||||
|
||||
func markAsUnreadForCurrentArticle() {
|
||||
if let article = currentArticle {
|
||||
markArticlesWithUndo([article], statusKey: .read, flag: false)
|
||||
articlesWithManuallyChangedReadStatus.insert(article)
|
||||
}
|
||||
}
|
||||
|
||||
func toggleReadForCurrentArticle() {
|
||||
if let article = currentArticle {
|
||||
toggleRead(article)
|
||||
articlesWithManuallyChangedReadStatus.insert(article)
|
||||
}
|
||||
}
|
||||
|
||||
func toggleRead(_ article: Article) {
|
||||
guard !article.status.read || article.isAvailableToMarkUnread else { return }
|
||||
markArticlesWithUndo([article], statusKey: .read, flag: !article.status.read)
|
||||
articlesWithManuallyChangedReadStatus.insert(article)
|
||||
}
|
||||
|
||||
func toggleStarredForCurrentArticle() {
|
||||
|
Loading…
Reference in New Issue
Block a user