Handle unread count did change notification in Account.

This commit is contained in:
Brent Simmons 2017-10-13 06:50:33 -07:00
parent 4897181909
commit 505f4bcdba
2 changed files with 19 additions and 2 deletions

View File

@ -289,8 +289,12 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
} }
@objc func unreadCountDidChange(_ note: Notification) { @objc func unreadCountDidChange(_ note: Notification) {
if let object = note.object as? AnyObject {
if objectIsChild(object) {
updateUnreadCount()
}
}
} }
// MARK: - Equatable // MARK: - Equatable

View File

@ -1,3 +1,4 @@
// //
// Container.swift // Container.swift
// Evergreen // Evergreen
@ -19,6 +20,8 @@ public protocol Container {
var children: [AnyObject] { get } var children: [AnyObject] { get }
func objectIsChild(_ object: AnyObject) -> Bool
//Recursive //Recursive
func flattenedFeeds() -> Set<Feed> func flattenedFeeds() -> Set<Feed>
func hasFeed(with feedID: String) -> Bool func hasFeed(with feedID: String) -> Bool
@ -32,6 +35,16 @@ public protocol Container {
public extension Container { public extension Container {
func objectIsChild(_ object: AnyObject) -> Bool {
for child in children {
if object === child {
return true
}
}
return false
}
func flattenedFeeds() -> Set<Feed> { func flattenedFeeds() -> Set<Feed> {
var feeds = Set<Feed>() var feeds = Set<Feed>()