Restore selection when currently select feed unread count changes

This commit is contained in:
Maurice Parker 2019-07-27 15:05:21 -05:00
parent adb6309872
commit 978aeeee80
1 changed files with 11 additions and 1 deletions

View File

@ -103,7 +103,9 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
return
}
tableView.reloadRows(at: [indexPath], with: .automatic)
performBlockAndRestoreSelection {
tableView.reloadRows(at: [indexPath], with: .automatic)
}
}
@ -672,4 +674,12 @@ private extension MasterFeedViewController {
}
}
func performBlockAndRestoreSelection(_ block: (() -> Void)) {
let indexPaths = tableView.indexPathsForSelectedRows
block()
indexPaths?.forEach { [weak self] indexPath in
self?.tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
}
}
}