diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 93637ca39..e6f13fe29 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -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) } diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 9a2105f6c..0ef3d0e61 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -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 }