Reenabled mac toolbar validation
This commit is contained in:
parent
dabf471db7
commit
5c8aaed54c
|
@ -128,20 +128,31 @@ private extension SceneModel {
|
|||
|
||||
// MARK: Subscriptions
|
||||
func subscribeToToolbarChangeEvents() {
|
||||
// NotificationCenter.default.publisher(for: .UnreadCountDidChange)
|
||||
// .compactMap { $0.object as? AccountManager }
|
||||
// .sink { [weak self] accountManager in
|
||||
// self?.updateNextUnreadButtonState(accountManager: accountManager)
|
||||
// }.store(in: &cancellables)
|
||||
//
|
||||
// let blankNotification = Notification(name: .StatusesDidChange)
|
||||
// let statusesDidChangePublisher = NotificationCenter.default.publisher(for: .StatusesDidChange).prepend(blankNotification)
|
||||
// let combinedPublisher = timelineModel.$articles.combineLatest(timelineModel.$selectedArticles, statusesDidChangePublisher)
|
||||
//
|
||||
// combinedPublisher.sink { [weak self] (articles, selectedArticles, _) in
|
||||
// self?.updateMarkAllAsReadButtonsState(articles: articles)
|
||||
// self?.updateArticleButtonsState(selectedArticles: selectedArticles)
|
||||
// }.store(in: &cancellables)
|
||||
guard let selectedArticlesPublisher = timelineModel.selectedArticlesPublisher,
|
||||
let articlesPublisher = timelineModel.articlesPublisher else { return }
|
||||
|
||||
NotificationCenter.default.publisher(for: .UnreadCountDidChange)
|
||||
.compactMap { $0.object as? AccountManager }
|
||||
.sink { [weak self] accountManager in
|
||||
self?.updateNextUnreadButtonState(accountManager: accountManager)
|
||||
}.store(in: &cancellables)
|
||||
|
||||
let blankNotification = Notification(name: .StatusesDidChange)
|
||||
let statusesDidChangePublisher = NotificationCenter.default.publisher(for: .StatusesDidChange).prepend(blankNotification)
|
||||
|
||||
statusesDidChangePublisher
|
||||
.combineLatest(selectedArticlesPublisher)
|
||||
.sink { [weak self] _, selectedArticles in
|
||||
self?.updateArticleButtonsState(selectedArticles: selectedArticles)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
statusesDidChangePublisher
|
||||
.combineLatest(articlesPublisher)
|
||||
.sink { [weak self] _, articles in
|
||||
self?.updateMarkAllAsReadButtonsState(articles: articles)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func subscribeToAccountSyncErrors() {
|
||||
|
|
|
@ -31,6 +31,7 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
|||
@Published var isReadFiltered: Bool? = nil
|
||||
|
||||
var timelineItemsPublisher: AnyPublisher<OrderedDictionary<String, TimelineItem>, Never>?
|
||||
var articlesPublisher: AnyPublisher<[Article], Never>?
|
||||
var selectedTimelineItemsPublisher: AnyPublisher<[TimelineItem], Never>?
|
||||
var selectedArticlesPublisher: AnyPublisher<[Article], Never>?
|
||||
|
||||
|
@ -80,6 +81,7 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
|||
// }.store(in: &cancellables)
|
||||
// }
|
||||
|
||||
// TODO: Don't forget to redo this!!!
|
||||
func subscribeToReadFilterChanges() {
|
||||
guard let selectedFeedsPublisher = delegate?.selectedFeedsPublisher else { return }
|
||||
|
||||
|
@ -132,6 +134,12 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
|||
.share(replay: 1)
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
articlesPublisher = timelineItemsPublisher!
|
||||
.map { timelineItems in
|
||||
timelineItems.values.values.map { $0.article }
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
// Set the timeline name for display
|
||||
selectedFeedsPublisher
|
||||
.map { feeds -> String in
|
||||
|
|
Loading…
Reference in New Issue