Avoid redundant shadow table rebuilds when auto-expanding containers.

This commit is contained in:
Maurice Parker 2020-02-18 09:30:58 -08:00
parent f1de105a65
commit f79eaf7c19
1 changed files with 14 additions and 18 deletions

View File

@ -405,7 +405,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
} }
func selectFirstUnreadInAllUnread() { func selectFirstUnreadInAllUnread() {
expand(SmartFeedsController.shared) markExpanded(SmartFeedsController.shared)
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.unreadFeed) { self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.unreadFeed) {
self.selectFeed(SmartFeedsController.shared.unreadFeed) { self.selectFeed(SmartFeedsController.shared.unreadFeed) {
self.selectFirstUnreadArticleInTimeline() self.selectFirstUnreadArticleInTimeline()
@ -646,8 +646,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
return false return false
} }
func expand(_ containerIdentifiable: ContainerIdentifiable) { func expand(_ node: Node) {
guard !isExpanded(containerIdentifiable) else { return } guard let containerIdentifiable = node.representedObject as? ContainerIdentifiable else {
return
}
markExpanded(containerIdentifiable) markExpanded(containerIdentifiable)
animatingChanges = true animatingChanges = true
@ -655,12 +657,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
animatingChanges = false animatingChanges = false
} }
func expand(_ node: Node) {
if let containerIdentifiable = node.representedObject as? ContainerIdentifiable {
expand(containerIdentifiable)
}
}
func expandAllSectionsAndFolders() { func expandAllSectionsAndFolders() {
for sectionNode in treeController.rootNode.childNodes { for sectionNode in treeController.rootNode.childNodes {
markExpanded(sectionNode) markExpanded(sectionNode)
@ -764,21 +760,21 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
} }
func selectTodayFeed() { func selectTodayFeed() {
expand(SmartFeedsController.shared) markExpanded(SmartFeedsController.shared)
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.todayFeed) { self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.todayFeed) {
self.selectFeed(SmartFeedsController.shared.todayFeed, animations: [.navigation, .scroll]) self.selectFeed(SmartFeedsController.shared.todayFeed, animations: [.navigation, .scroll])
} }
} }
func selectAllUnreadFeed() { func selectAllUnreadFeed() {
expand(SmartFeedsController.shared) markExpanded(SmartFeedsController.shared)
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.unreadFeed) { self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.unreadFeed) {
self.selectFeed(SmartFeedsController.shared.unreadFeed, animations: [.navigation, .scroll]) self.selectFeed(SmartFeedsController.shared.unreadFeed, animations: [.navigation, .scroll])
} }
} }
func selectStarredFeed() { func selectStarredFeed() {
expand(SmartFeedsController.shared) markExpanded(SmartFeedsController.shared)
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.starredFeed) { self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.starredFeed) {
self.selectFeed(SmartFeedsController.shared.starredFeed, animations: [.navigation, .scroll]) self.selectFeed(SmartFeedsController.shared.starredFeed, animations: [.navigation, .scroll])
} }
@ -1045,9 +1041,9 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
let parentFolder = account.sortedFolders?.first(where: { $0.objectIsChild(webFeed) }) let parentFolder = account.sortedFolders?.first(where: { $0.objectIsChild(webFeed) })
expand(account) markExpanded(account)
if let parentFolder = parentFolder { if let parentFolder = parentFolder {
expand(parentFolder) markExpanded(parentFolder)
} }
if let webFeedFeedID = webFeed.feedID { if let webFeedFeedID = webFeed.feedID {
@ -2012,7 +2008,7 @@ private extension SceneCoordinator {
case .smartFeed: case .smartFeed:
guard let smartFeed = SmartFeedsController.shared.find(by: feedIdentifier) else { return } guard let smartFeed = SmartFeedsController.shared.find(by: feedIdentifier) else { return }
expand(SmartFeedsController.shared) markExpanded(SmartFeedsController.shared)
rebuildBackingStores() { rebuildBackingStores() {
self.treeControllerDelegate.resetFilterExceptions() self.treeControllerDelegate.resetFilterExceptions()
if let indexPath = self.indexPathFor(smartFeed) { if let indexPath = self.indexPathFor(smartFeed) {
@ -2031,7 +2027,7 @@ private extension SceneCoordinator {
return return
} }
expand(account) markExpanded(account)
rebuildBackingStores() { rebuildBackingStores() {
self.treeControllerDelegate.resetFilterExceptions() self.treeControllerDelegate.resetFilterExceptions()