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

@ -290,7 +290,11 @@ 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

View File

@ -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<Feed>
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<Feed> {
var feeds = Set<Feed>()