mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-27 01:52:30 +01:00
Reimplement starred toolbar toggle
This commit is contained in:
parent
f793e1b02d
commit
d28a672378
@ -73,7 +73,7 @@ final class SceneModel: ObservableObject {
|
||||
|
||||
/// Toggles the star status for the selected articles
|
||||
func toggleStarredStatusForSelectedArticles() {
|
||||
// timelineModel.toggleStarredStatusForSelectedArticles()
|
||||
timelineModel.toggleStarredStatusForSelectedArticlesSubject.send()
|
||||
}
|
||||
|
||||
/// Opens the selected article in an external browser
|
||||
|
@ -37,7 +37,7 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
||||
var articleStatusChangePublisher: AnyPublisher<Set<String>, Never>?
|
||||
|
||||
var toggleReadStatusForSelectedArticlesSubject = PassthroughSubject<Void, Never>()
|
||||
|
||||
var toggleStarredStatusForSelectedArticlesSubject = PassthroughSubject<Void, Never>()
|
||||
|
||||
var readFilterEnabledTable = [FeedIdentifier: Bool]()
|
||||
|
||||
@ -270,8 +270,21 @@ private extension TimelineModel {
|
||||
return (selectedArticles, ArticleStatus.Key.read, false)
|
||||
}
|
||||
}
|
||||
|
||||
let toggleStarred = toggleStarredStatusForSelectedArticlesSubject
|
||||
.withLatestFrom(selectedArticlesPublisher)
|
||||
.filter { !$0.isEmpty }
|
||||
.map {selectedArticles -> ([Article], ArticleStatus.Key, Bool) in
|
||||
if selectedArticles.anyArticleIsUnstarred() {
|
||||
return (selectedArticles, ArticleStatus.Key.starred, true)
|
||||
} else {
|
||||
return (selectedArticles, ArticleStatus.Key.read, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toggleReadPublisher
|
||||
.merge(with: toggleStarred)
|
||||
.sink { [weak self] (articles, key, flag) in
|
||||
if let undoManager = self?.undoManager,
|
||||
let markReadCommand = MarkStatusCommand(initialArticles: articles, statusKey: key, flag: flag, undoManager: undoManager) {
|
||||
|
Loading…
Reference in New Issue
Block a user