Add rebuildTreeAndRestoreSelection method and use it where appropriate in SidebarViewController.

This commit is contained in:
Brent Simmons 2019-02-05 21:00:53 -08:00
parent 3a5741a5dd
commit 7ce4a21194
1 changed files with 9 additions and 4 deletions

View File

@ -83,13 +83,11 @@ import RSCore
} }
@objc func containerChildrenDidChange(_ note: Notification) { @objc func containerChildrenDidChange(_ note: Notification) {
rebuildTreeAndRestoreSelection()
rebuildTreeAndReloadDataIfNeeded()
} }
@objc func batchUpdateDidPerform(_ notification: Notification) { @objc func batchUpdateDidPerform(_ notification: Notification) {
rebuildTreeAndRestoreSelection()
rebuildTreeAndReloadDataIfNeeded()
} }
@objc func userDidAddFeed(_ notification: Notification) { @objc func userDidAddFeed(_ notification: Notification) {
@ -297,6 +295,13 @@ import RSCore
animatingChanges = false animatingChanges = false
} }
// MARK: - API
func rebuildTreeAndRestoreSelection() {
let savedSelection = selectedNodes
rebuildTreeAndReloadDataIfNeeded()
restoreSelection(to: savedSelection, sendNotificationIfChanged: true)
}
} }
// MARK: - NSUserInterfaceValidations // MARK: - NSUserInterfaceValidations