Update the SceneCoordinator to use the same lookup method to determine if the node should be getting its unread count from the SceneCoordinator.

This commit is contained in:
Maurice Parker 2020-01-16 15:24:48 -07:00
parent 333da704aa
commit 046162b303
2 changed files with 5 additions and 4 deletions

View File

@ -107,8 +107,8 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
var node: Node? = nil
if let coordinator = representedObject as? SceneCoordinator, let fetcher = coordinator.timelineFeed {
node = coordinator.rootNode.descendantNodeRepresentingObject(fetcher as AnyObject)
if let coordinator = representedObject as? SceneCoordinator, let feed = coordinator.timelineFeed {
node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject)
} else {
node = coordinator.rootNode.descendantNodeRepresentingObject(representedObject as AnyObject)
}

View File

@ -555,13 +555,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
func unreadCountFor(_ node: Node) -> Int {
// The coordinator supplies the unread count for the currently selected feed node
if let indexPath = currentFeedIndexPath, let selectedNode = nodeFor(indexPath), selectedNode == node {
// The coordinator supplies the unread count for the currently selected feed
if let feed = timelineFeed, let selectedNode = rootNode.descendantNodeRepresentingObject(feed as AnyObject), selectedNode == node {
return unreadCount
}
if let unreadCountProvider = node.representedObject as? UnreadCountProvider {
return unreadCountProvider.unreadCount
}
assertionFailure("This method should only be called for nodes that have an UnreadCountProvider as the represented object.")
return 0
}