Add Sidebar go to next functionality

This commit is contained in:
Maurice Parker
2020-07-19 13:23:08 -05:00
parent 7f60c69454
commit 3cbb4da788
3 changed files with 68 additions and 10 deletions

View File

@@ -120,6 +120,12 @@ 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 combinedPublisher = timelineModel.$articles.combineLatest(timelineModel.$selectedArticles,
NotificationCenter.default.publisher(for: .StatusesDidChange))
@@ -131,6 +137,14 @@ private extension SceneModel {
// MARK: Button State Updates
func updateNextUnreadButtonState(accountManager: AccountManager) {
if accountManager.unreadCount > 0 {
self.nextUnreadButtonState = false
} else {
self.nextUnreadButtonState = nil
}
}
func updateMarkAllAsReadButtonsState(articles: [Article]) {
if articles.canMarkAllAsRead() {
markAllAsReadButtonState = false