mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Restore the feed selection if an account containing the selection is expanded
This commit is contained in:
@@ -469,8 +469,6 @@ private extension MasterFeedViewController {
|
||||
}
|
||||
|
||||
func applyChanges(animate: Bool, completion: (() -> Void)? = nil) {
|
||||
let savedNode = selectedNode()
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Int, Node>()
|
||||
let sections = coordinator.allSections
|
||||
snapshot.appendSections(sections)
|
||||
@@ -480,7 +478,7 @@ private extension MasterFeedViewController {
|
||||
}
|
||||
|
||||
dataSource.apply(snapshot, animatingDifferences: animate) { [weak self] in
|
||||
self?.selectRow(node: savedNode)
|
||||
self?.restoreSelectionIfNecessary()
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
@@ -605,6 +603,15 @@ private extension MasterFeedViewController {
|
||||
self.applyChanges(animate: true)
|
||||
}
|
||||
|
||||
func restoreSelectionIfNecessary() {
|
||||
guard traitCollection.userInterfaceIdiom == .pad else {
|
||||
return
|
||||
}
|
||||
if let indexPath = coordinator.masterFeedIndexPathForCurrentTimeline(), indexPath != tableView.indexPathForSelectedRow {
|
||||
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
|
||||
}
|
||||
}
|
||||
|
||||
func makeFeedContextMenu(indexPath: IndexPath, includeDeleteRename: Bool) -> UIContextMenuConfiguration {
|
||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { [ weak self] suggestedActions in
|
||||
|
||||
|
||||
@@ -467,6 +467,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
animatingChanges = false
|
||||
}
|
||||
|
||||
func masterFeedIndexPathForCurrentTimeline() -> IndexPath? {
|
||||
guard let node = treeController.rootNode.descendantNode(where: { return $0.representedObject === timelineFetcher as AnyObject }) else {
|
||||
return nil
|
||||
}
|
||||
return indexPathFor(node)
|
||||
}
|
||||
|
||||
func indexForArticleID(_ articleID: String?) -> Int? {
|
||||
guard let articleID = articleID else { return nil }
|
||||
updateArticleRowMapIfNeeded()
|
||||
|
||||
Reference in New Issue
Block a user