Fix tableview access on main thread

This commit is contained in:
relikd
2020-05-13 21:55:02 +02:00
parent 2d35c863e4
commit 4092a9ba55

View File

@@ -103,9 +103,14 @@ extension IncrementalDataSourceUpdate {
dataSource.insert(obj, at: to) dataSource.insert(obj, at: to)
if shouldLiveUpdateIncrementalDataSource() { if shouldLiveUpdateIncrementalDataSource() {
DispatchQueue.main.sync { DispatchQueue.main.sync {
let cell = tableView.cellForRow(at: IndexPath(row: from)) if tableView.isFrontmost {
cell?.detailTextLabel?.text = obj.detailCellText let source = IndexPath(row: from)
tableView.safeMoveRow(from, to: to) let cell = tableView.cellForRow(at: source)
cell?.detailTextLabel?.text = obj.detailCellText
tableView.moveRow(at: source, to: IndexPath(row: to))
} else {
tableView.reloadData()
}
} }
} }
didUpdateIncrementalDataSource(.Move, row: from, moveTo: to) didUpdateIncrementalDataSource(.Move, row: from, moveTo: to)