Change to reload the individual row instead of just changing its contents

This commit is contained in:
Maurice Parker 2019-08-28 20:21:50 -05:00
parent 7062744758
commit be8c14bc65
1 changed files with 9 additions and 6 deletions

View File

@ -389,10 +389,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
coordinator.expand(indexPath)
// I don't think this should be necessary when using diffable datasources, but they don't
// always reload cells that you want them too.
configureCellsForRepresentedObject(parent.representedObject)
reloadNode(parent)
self.applyChanges(animate: true) { [weak self] in
if let indexPath = self?.coordinator.indexPathFor(node) {
@ -428,6 +425,12 @@ private extension MasterFeedViewController {
addNewItemButton.isEnabled = !AccountManager.shared.activeAccounts.isEmpty
}
func reloadNode(_ node: Node) {
var snapshot = dataSource.snapshot()
snapshot.reloadItems([node])
dataSource.apply(snapshot)
}
func applyChanges(animate: Bool, completion: (() -> Void)? = nil) {
let selectedNode: Node? = {
@ -725,7 +728,7 @@ private extension MasterFeedViewController {
feed.rename(to: name) { result in
switch result {
case .success:
self?.configureCellsForRepresentedObject(feed)
self?.reloadNode(node)
case .failure(let error):
self?.presentError(error)
}
@ -734,7 +737,7 @@ private extension MasterFeedViewController {
folder.rename(to: name) { result in
switch result {
case .success:
self?.configureCellsForRepresentedObject(folder)
self?.reloadNode(node)
case .failure(let error):
self?.presentError(error)
}