mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Respond to sidebar Feed name updates
This commit is contained in:
@@ -71,6 +71,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner, Ma
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(configureContextMenu(_:)), name: .ActiveExtensionPointsDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
|
||||
|
||||
refreshControl = UIRefreshControl()
|
||||
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
|
||||
@@ -139,6 +140,13 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner, Ma
|
||||
}
|
||||
}
|
||||
|
||||
@objc func displayNameDidChange(_ note: Notification) {
|
||||
guard let object = note.object as? AnyObject else {
|
||||
return
|
||||
}
|
||||
reloadCell(for: object)
|
||||
}
|
||||
|
||||
@objc func contentSizeCategoryDidChange(_ note: Notification) {
|
||||
resetEstimatedRowHeight()
|
||||
tableView.reloadData()
|
||||
@@ -831,6 +839,12 @@ private extension MasterFeedViewController {
|
||||
completion(cell as! MasterFeedTableViewCell, indexPath)
|
||||
}
|
||||
}
|
||||
|
||||
private func reloadCell(for object: AnyObject) {
|
||||
guard let indexPath = coordinator.indexPathFor(object) else { return }
|
||||
tableView.reloadRows(at: [indexPath], with: .none)
|
||||
restoreSelectionIfNecessary(adjustScroll: false)
|
||||
}
|
||||
|
||||
private func reloadAllVisibleCells(completion: (() -> Void)? = nil) {
|
||||
guard let indexPaths = tableView.indexPathsForVisibleRows else { return }
|
||||
|
||||
@@ -619,6 +619,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, Logging {
|
||||
return shadowTable[indexPath.section].feedNodes[indexPath.row].node
|
||||
}
|
||||
|
||||
func indexPathFor(_ object: AnyObject) -> IndexPath? {
|
||||
guard let node = treeController.rootNode.descendantNodeRepresentingObject(object) else {
|
||||
return nil
|
||||
}
|
||||
return indexPathFor(node)
|
||||
}
|
||||
|
||||
func indexPathFor(_ node: Node) -> IndexPath? {
|
||||
for i in 0..<shadowTable.count {
|
||||
if let row = shadowTable[i].feedNodes.firstIndex(of: FeedNode(node)) {
|
||||
@@ -1626,13 +1633,6 @@ private extension SceneCoordinator {
|
||||
}
|
||||
}
|
||||
|
||||
func indexPathFor(_ object: AnyObject) -> IndexPath? {
|
||||
guard let node = treeController.rootNode.descendantNodeRepresentingObject(object) else {
|
||||
return nil
|
||||
}
|
||||
return indexPathFor(node)
|
||||
}
|
||||
|
||||
func setTimelineFeed(_ feed: Feed?, animated: Bool, completion: (() -> Void)? = nil) {
|
||||
timelineFeed = feed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user