mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Stubbed out menu item keyboard shortcuts and implemented the numbered ones
This commit is contained in:
@@ -421,6 +421,21 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
}
|
||||
}
|
||||
|
||||
func ensureSectionIsExpanded(_ sectionIndex: Int, completion: (() -> Void)? = nil) {
|
||||
guard let sectionNode = coordinator.rootNode.childAtIndex(sectionIndex) else {
|
||||
return
|
||||
}
|
||||
|
||||
if !coordinator.isExpanded(sectionNode) {
|
||||
coordinator.expand(section: sectionIndex)
|
||||
self.applyChanges(animate: true) {
|
||||
completion?()
|
||||
}
|
||||
} else {
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
|
||||
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
|
||||
|
||||
guard let node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else {
|
||||
@@ -481,12 +496,10 @@ private extension MasterFeedViewController {
|
||||
}
|
||||
|
||||
func reloadNode(_ node: Node) {
|
||||
let savedNode = selectedNode()
|
||||
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reloadItems([node])
|
||||
dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in
|
||||
self?.selectRow(node: savedNode)
|
||||
self?.restoreSelectionIfNecessary()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,21 +517,6 @@ private extension MasterFeedViewController {
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
|
||||
func selectedNode() -> Node? {
|
||||
if let selectedIndexPath = tableView.indexPathForSelectedRow {
|
||||
return coordinator.nodeFor(selectedIndexPath)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func selectRow(node: Node?) {
|
||||
if let nodeToSelect = node, let selectingIndexPath = coordinator.indexPathFor(nodeToSelect) {
|
||||
tableView.selectRow(at: selectingIndexPath, animated: false, scrollPosition: .none)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func makeDataSource() -> UITableViewDiffableDataSource<Int, Node> {
|
||||
return MasterFeedDataSource(coordinator: coordinator, errorHandler: ErrorHandler.present(self), tableView: tableView, cellProvider: { [weak self] tableView, indexPath, node in
|
||||
|
||||
Reference in New Issue
Block a user