From bfa8d26a328928808eeed585a33aff94f09874d9 Mon Sep 17 00:00:00 2001 From: Bas Broek Date: Tue, 23 Jan 2018 03:34:17 +0100 Subject: [PATCH] Only update the mark all state, don't re-init the button (#1457) * Only update the mark all state, don't re-init the button * Don't forget to update state --- .../Notifications/NotificationsViewController.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Classes/Notifications/NotificationsViewController.swift b/Classes/Notifications/NotificationsViewController.swift index 583e0031..02af9f35 100644 --- a/Classes/Notifications/NotificationsViewController.swift +++ b/Classes/Notifications/NotificationsViewController.swift @@ -123,7 +123,7 @@ FlatCacheListener { navigationController?.pushViewController(controller, animated: trueUnlessReduceMotionEnabled) } - func resetRightBarItem() { + func resetRightBarItem(updatingState updateState: Bool = true) { let item = UIBarButtonItem( image: UIImage(named: "check"), style: .plain, @@ -132,7 +132,9 @@ FlatCacheListener { ) item.accessibilityLabel = NSLocalizedString("Mark notifications read", comment: "") navigationItem.rightBarButtonItem = item - updateUnreadState(count: notificationIDs.count) + if updateState { + updateUnreadState(count: notificationIDs.count) + } } private func updateUnreadState(count: Int) { @@ -159,6 +161,10 @@ FlatCacheListener { // clear all badges BadgeNotifications.update(count: 0) + + // change the spinner to the mark all item + // don't update state here; it is managed by `fetch` + self.resetRightBarItem(updatingState: false) } else { generator.notificationOccurred(.error) } @@ -218,7 +224,7 @@ FlatCacheListener { } // set after updating so self.models has already been changed - self.resetRightBarItem() + updateUnreadState(count: notificationIDs.count) } private func rebuildAndUpdate(