Make Folder watch for children-did-change notifications — when its own children change, update the unread count. Fix #322.

This commit is contained in:
Brent Simmons 2018-02-12 22:22:06 -08:00
parent 0762074e91
commit 192439abe7
1 changed files with 7 additions and 1 deletions

View File

@ -58,6 +58,7 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
self.hashValue = folderID
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(childrenDidChange(_:)), name: .ChildrenDidChange, object: self)
}
// MARK: - Disk Dictionary
@ -130,7 +131,7 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
return true
}
// MARK: Notifications
// MARK: - Notifications
@objc func unreadCountDidChange(_ note: Notification) {
@ -141,6 +142,11 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
}
}
@objc func childrenDidChange(_ note: Notification) {
updateUnreadCount()
}
// MARK: - Equatable
static public func ==(lhs: Folder, rhs: Folder) -> Bool {