From 505f4bcdba3a214c581cbf7b93494aeb597e0477 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 13 Oct 2017 06:50:33 -0700 Subject: [PATCH] Handle unread count did change notification in Account. --- Frameworks/Account/Account.swift | 8 ++++++-- Frameworks/Account/Container.swift | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index ef2d6fb32..0d9ab4443 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -289,8 +289,12 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } @objc func unreadCountDidChange(_ note: Notification) { - - + + if let object = note.object as? AnyObject { + if objectIsChild(object) { + updateUnreadCount() + } + } } // MARK: - Equatable diff --git a/Frameworks/Account/Container.swift b/Frameworks/Account/Container.swift index e60b91db2..7192da2ed 100644 --- a/Frameworks/Account/Container.swift +++ b/Frameworks/Account/Container.swift @@ -1,3 +1,4 @@ + // // Container.swift // Evergreen @@ -19,6 +20,8 @@ public protocol Container { var children: [AnyObject] { get } + func objectIsChild(_ object: AnyObject) -> Bool + //Recursive func flattenedFeeds() -> Set func hasFeed(with feedID: String) -> Bool @@ -32,6 +35,16 @@ public protocol Container { public extension Container { + func objectIsChild(_ object: AnyObject) -> Bool { + + for child in children { + if object === child { + return true + } + } + return false + } + func flattenedFeeds() -> Set { var feeds = Set()