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) {
|
func markArticles(_ articles: [Article], read: Bool) {
|
||||||
markArticles(articles, statusKey: .read, flag: read)
|
markArticles(articles, statusKey: .read, flag: read)
|
||||||
|
for article in articles {
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func markArticles(_ articles: [Article], starred: Bool) {
|
func markArticles(_ articles: [Article], starred: Bool) {
|
||||||
|
@ -138,6 +138,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
}
|
}
|
||||||
|
|
||||||
var undoableCommands = [UndoableCommand]()
|
var undoableCommands = [UndoableCommand]()
|
||||||
|
|
||||||
|
var articlesWithManuallyChangedReadStatus: Set<Article> = Set()
|
||||||
|
|
||||||
private var fetchSerialNumber = 0
|
private var fetchSerialNumber = 0
|
||||||
private let fetchRequestQueue = FetchRequestQueue()
|
private let fetchRequestQueue = FetchRequestQueue()
|
||||||
private var exceptionArticleFetcher: ArticleFetcher?
|
private var exceptionArticleFetcher: ArticleFetcher?
|
||||||
@ -341,7 +344,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let firstVisibleRowIndex = tableView.rows(in: tableView.visibleRect).location
|
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 {
|
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: unreadArticlesScrolledAway, markingRead: true, undoManager: undoManager) else {
|
||||||
return
|
return
|
||||||
@ -370,6 +375,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
runCommand(markReadCommand)
|
runCommand(markReadCommand)
|
||||||
|
for article in selectedArticles {
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func markSelectedArticlesAsUnread(_ sender: Any?) {
|
@IBAction func markSelectedArticlesAsUnread(_ sender: Any?) {
|
||||||
@ -377,6 +385,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
runCommand(markUnreadCommand)
|
runCommand(markUnreadCommand)
|
||||||
|
for article in selectedArticles {
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func copy(_ sender: Any?) {
|
@IBAction func copy(_ sender: Any?) {
|
||||||
@ -928,6 +939,7 @@ extension TimelineViewController: NSTableViewDelegate {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.runCommand(markUnreadCommand)
|
self.runCommand(markUnreadCommand)
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func toggleArticleStarred(_ article: Article) {
|
private func toggleArticleStarred(_ article: Article) {
|
||||||
|
@ -527,7 +527,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||||||
return
|
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)
|
coordinator.markAllAsRead(unreadArticlesScrolledAway)
|
||||||
|
|
||||||
|
@ -182,6 +182,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
|||||||
private(set) var showFeedNames = ShowFeedName.none
|
private(set) var showFeedNames = ShowFeedName.none
|
||||||
private(set) var showIcons = false
|
private(set) var showIcons = false
|
||||||
|
|
||||||
|
var articlesWithManuallyChangedReadStatus: Set<Article> = Set()
|
||||||
|
|
||||||
var prevFeedIndexPath: IndexPath? {
|
var prevFeedIndexPath: IndexPath? {
|
||||||
guard let indexPath = currentFeedIndexPath else {
|
guard let indexPath = currentFeedIndexPath else {
|
||||||
return nil
|
return nil
|
||||||
@ -783,6 +785,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
articlesWithManuallyChangedReadStatus.removeAll()
|
||||||
|
|
||||||
currentFeedIndexPath = indexPath
|
currentFeedIndexPath = indexPath
|
||||||
masterFeedViewController.updateFeedSelection(animations: animations)
|
masterFeedViewController.updateFeedSelection(animations: animations)
|
||||||
|
|
||||||
@ -1073,24 +1077,28 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
|||||||
func markAsReadForCurrentArticle() {
|
func markAsReadForCurrentArticle() {
|
||||||
if let article = currentArticle {
|
if let article = currentArticle {
|
||||||
markArticlesWithUndo([article], statusKey: .read, flag: true)
|
markArticlesWithUndo([article], statusKey: .read, flag: true)
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func markAsUnreadForCurrentArticle() {
|
func markAsUnreadForCurrentArticle() {
|
||||||
if let article = currentArticle {
|
if let article = currentArticle {
|
||||||
markArticlesWithUndo([article], statusKey: .read, flag: false)
|
markArticlesWithUndo([article], statusKey: .read, flag: false)
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleReadForCurrentArticle() {
|
func toggleReadForCurrentArticle() {
|
||||||
if let article = currentArticle {
|
if let article = currentArticle {
|
||||||
toggleRead(article)
|
toggleRead(article)
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleRead(_ article: Article) {
|
func toggleRead(_ article: Article) {
|
||||||
guard !article.status.read || article.isAvailableToMarkUnread else { return }
|
guard !article.status.read || article.isAvailableToMarkUnread else { return }
|
||||||
markArticlesWithUndo([article], statusKey: .read, flag: !article.status.read)
|
markArticlesWithUndo([article], statusKey: .read, flag: !article.status.read)
|
||||||
|
articlesWithManuallyChangedReadStatus.insert(article)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleStarredForCurrentArticle() {
|
func toggleStarredForCurrentArticle() {
|
||||||
|
Loading…
Reference in New Issue
Block a user