Merge pull request #2134 from Mackarous/master
Disable selection while applying snapshot
This commit is contained in:
commit
3b2fcb74fd
|
@ -640,12 +640,23 @@ private extension MasterFeedViewController {
|
||||||
|
|
||||||
func queueApply(snapshot: NSDiffableDataSourceSnapshot<Node, Node>, animatingDifferences: Bool = true, completion: (() -> Void)? = nil) {
|
func queueApply(snapshot: NSDiffableDataSourceSnapshot<Node, Node>, animatingDifferences: Bool = true, completion: (() -> Void)? = nil) {
|
||||||
let operation = MasterFeedDataSourceOperation(dataSource: dataSource, snapshot: snapshot, animating: animatingDifferences)
|
let operation = MasterFeedDataSourceOperation(dataSource: dataSource, snapshot: snapshot, animating: animatingDifferences)
|
||||||
operation.completionBlock = { _ in
|
operation.completionBlock = { [weak self] _ in
|
||||||
|
self?.enableTableViewSelection()
|
||||||
completion?()
|
completion?()
|
||||||
}
|
}
|
||||||
|
disableTableViewSelectionIfNecessary()
|
||||||
operationQueue.add(operation)
|
operationQueue.add(operation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func disableTableViewSelectionIfNecessary() {
|
||||||
|
// We only need to disable tableView selection if the feeds are filtered by unread
|
||||||
|
guard coordinator.isReadFeedsFiltered else { return }
|
||||||
|
tableView.allowsSelection = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private func enableTableViewSelection() {
|
||||||
|
tableView.allowsSelection = true
|
||||||
|
}
|
||||||
|
|
||||||
func makeDataSource() -> MasterFeedDataSource {
|
func makeDataSource() -> MasterFeedDataSource {
|
||||||
let dataSource = MasterFeedDataSource(tableView: tableView, cellProvider: { [weak self] tableView, indexPath, node in
|
let dataSource = MasterFeedDataSource(tableView: tableView, cellProvider: { [weak self] tableView, indexPath, node in
|
||||||
|
|
Loading…
Reference in New Issue