Correct about/below mark as read to take into account multiple select
This commit is contained in:
parent
11bd3dce22
commit
538d886bf4
|
@ -173,14 +173,17 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
func canMarkAboveAsRead(_ article: Article) -> Bool {
|
func canMarkAboveAsRead(_ article: Article) -> Bool {
|
||||||
|
let article = correctedAboveArticle(article)
|
||||||
return articles.articlesAbove(article: article).canMarkAllAsRead()
|
return articles.articlesAbove(article: article).canMarkAllAsRead()
|
||||||
}
|
}
|
||||||
|
|
||||||
func canMarkBelowAsRead(_ article: Article) -> Bool {
|
func canMarkBelowAsRead(_ article: Article) -> Bool {
|
||||||
|
let article = correctedBelowArticle(article)
|
||||||
return articles.articlesBelow(article: article).canMarkAllAsRead()
|
return articles.articlesBelow(article: article).canMarkAllAsRead()
|
||||||
}
|
}
|
||||||
|
|
||||||
func markAboveAsRead(_ article: Article) {
|
func markAboveAsRead(_ article: Article) {
|
||||||
|
let article = correctedAboveArticle(article)
|
||||||
let articlesToMark = articles.articlesAbove(article: article)
|
let articlesToMark = articles.articlesAbove(article: article)
|
||||||
guard !articlesToMark.isEmpty else { return }
|
guard !articlesToMark.isEmpty else { return }
|
||||||
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articlesToMark, markingRead: true, undoManager: undoManager) else {
|
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articlesToMark, markingRead: true, undoManager: undoManager) else {
|
||||||
|
@ -190,6 +193,7 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
func markBelowAsRead(_ article: Article) {
|
func markBelowAsRead(_ article: Article) {
|
||||||
|
let article = correctedBelowArticle(article)
|
||||||
let articlesToMark = articles.articlesBelow(article: article)
|
let articlesToMark = articles.articlesBelow(article: article)
|
||||||
guard !articlesToMark.isEmpty else { return }
|
guard !articlesToMark.isEmpty else { return }
|
||||||
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articlesToMark, markingRead: true, undoManager: undoManager) else {
|
guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articlesToMark, markingRead: true, undoManager: undoManager) else {
|
||||||
|
@ -226,6 +230,22 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
||||||
|
|
||||||
private extension TimelineModel {
|
private extension TimelineModel {
|
||||||
|
|
||||||
|
func correctedAboveArticle(_ article: Article) -> Article {
|
||||||
|
if selectedArticles.contains(article) {
|
||||||
|
return selectedArticles.first!
|
||||||
|
} else {
|
||||||
|
return article
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func correctedBelowArticle(_ article: Article) -> Article {
|
||||||
|
if selectedArticles.contains(article) {
|
||||||
|
return selectedArticles.last!
|
||||||
|
} else {
|
||||||
|
return article
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Notifications
|
// MARK: Notifications
|
||||||
|
|
||||||
@objc func statusesDidChange(_ note: Notification) {
|
@objc func statusesDidChange(_ note: Notification) {
|
||||||
|
|
Loading…
Reference in New Issue