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

@@ -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)

View File

@@ -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() {