Implement better scroll interference avoidance strategy.

This commit is contained in:
Maurice Parker 2019-11-13 15:31:14 -06:00
parent 38535910ef
commit ef84acc02d
1 changed files with 9 additions and 3 deletions

View File

@ -99,11 +99,17 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
node = coordinator.rootNode.descendantNodeRepresentingObject(representedObject as AnyObject)
}
if let node = node, dataSource.indexPath(for: node) != nil {
// This can stop the scrolling of the disclose function if we don't delay it enough to complete
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
// Only do the reload of the node when absolutely necessary. It can stop programatic scrolling from
// completing if called to soon after a selectRow where scrolling is necessary. See discloseFeed.
if let node = node,
let indexPath = dataSource.indexPath(for: node),
let cell = tableView.cellForRow(at: indexPath) as? MasterFeedTableViewCell,
let unreadCountProvider = node.representedObject as? UnreadCountProvider {
if cell.unreadCount != unreadCountProvider.unreadCount {
self.reloadNode(node)
}
}
}