Restore Mark All As Read in Feed context menu after making it performant

This commit is contained in:
Maurice Parker 2020-07-20 09:40:56 -05:00
parent 3b8db28f3d
commit 4bf4c6d6c2
2 changed files with 12 additions and 17 deletions

View File

@ -81,19 +81,17 @@ struct TimelineContextMenu: View {
}
}
// This thing isn't lazily initialized and gets called excessively even for things like selecting an article
// if let feed = timelineItem.article.webFeed, timelineModel.canMarkAllAsReadInFeed(feed) {
// Divider()
// Button {
// timelineModel.markAllAsReadInFeed(feed)
// } label: {
// Text("Mark All as Read in \(feed.nameForDisplay)")
// #if os(iOS)
// AppAssets.markAllAsReadImage
// #endif
// }
// }
if let feed = timelineItem.article.webFeed, timelineModel.canMarkAllAsReadInFeed(feed) {
Divider()
Button {
timelineModel.markAllAsReadInFeed(feed)
} label: {
Text("Mark All as Read in “\(feed.nameForDisplay)")
#if os(iOS)
AppAssets.markAllAsReadImage
#endif
}
}
if timelineModel.canOpenIndicatedArticleInBrowser(timelineItem.article) {
Divider()

View File

@ -238,10 +238,7 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
}
func canMarkAllAsReadInFeed(_ feed: Feed) -> Bool {
guard let articlesSet = try? feed.fetchArticles() else {
return false
}
return Array(articlesSet).canMarkAllAsRead()
return feed.unreadCount > 0
}
func markAllAsReadInFeed(_ feed: Feed) {