From 168020cba2fb1a1080a0e7b6d464ca8d5bf1d29b Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 24 Aug 2021 16:55:44 -0500 Subject: [PATCH] Always updates the tree controller when collapsing and expanding. Fixes #3040 --- iOS/MasterFeed/MasterFeedViewController.swift | 16 -------------- iOS/SceneCoordinator.swift | 22 ++++++------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 262f2c1ba..068bce323 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -511,33 +511,21 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { @objc func expandSelectedRows(_ sender: Any?) { if let indexPath = coordinator.currentFeedIndexPath, let containerID = dataSource.itemIdentifier(for: indexPath)?.containerID { coordinator.expand(containerID) - self.applyChanges(animated: true) { - self.reloadAllVisibleCells() - } } } @objc func collapseSelectedRows(_ sender: Any?) { if let indexPath = coordinator.currentFeedIndexPath, let containerID = dataSource.itemIdentifier(for: indexPath)?.containerID { coordinator.collapse(containerID) - self.applyChanges(animated: true) { - self.reloadAllVisibleCells() - } } } @objc func expandAll(_ sender: Any?) { coordinator.expandAllSectionsAndFolders() - self.applyChanges(animated: true) { - self.reloadAllVisibleCells() - } } @objc func collapseAllExceptForGroupItems(_ sender: Any?) { coordinator.collapseAllFolders() - self.applyChanges(animated: true) { - self.reloadAllVisibleCells() - } } @objc func markAllAsRead(_ sender: Any) { @@ -917,11 +905,9 @@ private extension MasterFeedViewController { if coordinator.isExpanded(sectionNode) { headerView.disclosureExpanded = false coordinator.collapse(sectionNode) - self.applyChanges(animated: true) } else { headerView.disclosureExpanded = true coordinator.expand(sectionNode) - self.applyChanges(animated: true) } } @@ -930,7 +916,6 @@ private extension MasterFeedViewController { return } coordinator.expand(containerID) - applyChanges(animated: true) } func collapse(_ cell: MasterFeedTableViewCell) { @@ -938,7 +923,6 @@ private extension MasterFeedViewController { return } coordinator.collapse(containerID) - applyChanges(animated: true) } func makeWebFeedContextMenu(identifier: MasterFeedTableViewIdentifier, indexPath: IndexPath, includeDeleteRename: Bool) -> UIContextMenuConfiguration { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 7bc4b4037..43ebb3c32 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -72,7 +72,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { private var fetchSerialNumber = 0 private let fetchRequestQueue = FetchRequestQueue() - private var animatingChanges = false private var expandedTable = Set() private var readFilterEnabledTable = [FeedIdentifier: Bool]() private var shadowTable = [[Node]]() @@ -446,6 +445,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { return } + guard note.object is Feed else { return } + queueRebuildBackingStores() } @@ -677,9 +678,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { func expand(_ containerID: ContainerIdentifier) { markExpanded(containerID) - animatingChanges = true - rebuildShadowTable() - animatingChanges = false + rebuildBackingStores() } func expand(_ node: Node) { @@ -696,16 +695,12 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } } } - animatingChanges = true - rebuildShadowTable() - animatingChanges = false + rebuildBackingStores() } func collapse(_ containerID: ContainerIdentifier) { unmarkExpanded(containerID) - animatingChanges = true - rebuildShadowTable() - animatingChanges = false + rebuildBackingStores() clearTimelineIfNoLongerAvailable() } @@ -716,16 +711,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { func collapseAllFolders() { for sectionNode in treeController.rootNode.childNodes { - unmarkExpanded(sectionNode) for topLevelNode in sectionNode.childNodes { if topLevelNode.representedObject is Folder { unmarkExpanded(topLevelNode) } } } - animatingChanges = true - rebuildShadowTable() - animatingChanges = false + rebuildBackingStores() clearTimelineIfNoLongerAvailable() } @@ -1446,7 +1438,7 @@ private extension SceneCoordinator { } func rebuildBackingStores(initialLoad: Bool = false, updateExpandedNodes: (() -> Void)? = nil, completion: (() -> Void)? = nil) { - if !animatingChanges && !BatchUpdate.shared.isPerforming { + if !BatchUpdate.shared.isPerforming { addToFilterExeptionsIfNecessary(timelineFeed) treeController.rebuild()