From 046162b303a4d7d2aa09035662888f666c614a57 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 16 Jan 2020 15:24:48 -0700 Subject: [PATCH] Update the SceneCoordinator to use the same lookup method to determine if the node should be getting its unread count from the SceneCoordinator. --- iOS/MasterFeed/MasterFeedViewController.swift | 4 ++-- iOS/SceneCoordinator.swift | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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 }