Fix data source update
This commit is contained in:
@@ -204,7 +204,10 @@ class FilterPipeline<T> {
|
|||||||
/// - Complexity: O(*n* + (*m*+1) log *n*), where *m* is the number of filters and *n* the number of elements in each filter / projection.
|
/// - Complexity: O(*n* + (*m*+1) log *n*), where *m* is the number of filters and *n* the number of elements in each filter / projection.
|
||||||
func update(_ obj: T, at index: Int) {
|
func update(_ obj: T, at index: Int) {
|
||||||
let status = processPipeline(with: obj, at: index)
|
let status = processPipeline(with: obj, at: index)
|
||||||
guard status.changed else { return }
|
guard status.changed else {
|
||||||
|
dataSource[index] = obj // we need to update anyway
|
||||||
|
return
|
||||||
|
}
|
||||||
let oldPos = display.deleteOld(index)
|
let oldPos = display.deleteOld(index)
|
||||||
dataSource[index] = obj
|
dataSource[index] = obj
|
||||||
guard status.display else {
|
guard status.display else {
|
||||||
@@ -212,16 +215,17 @@ class FilterPipeline<T> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let newPos = display.insertNew(index, previousIndex: oldPos)
|
let newPos = display.insertNew(index, previousIndex: oldPos)
|
||||||
guard cellAnimations else { return }
|
if cellAnimations {
|
||||||
if oldPos == -1 {
|
if oldPos == -1 {
|
||||||
delegate?.tableView.safeInsertRow(newPos, with: .left)
|
delegate?.tableView.safeInsertRow(newPos, with: .left)
|
||||||
} else {
|
|
||||||
if oldPos == newPos {
|
|
||||||
delegate?.tableView.safeReloadRow(oldPos)
|
|
||||||
} else {
|
} else {
|
||||||
delegate?.tableView.safeMoveRow(oldPos, to: newPos)
|
if oldPos == newPos {
|
||||||
if delegate?.tableView.isFrontmost ?? false {
|
delegate?.tableView.safeReloadRow(oldPos)
|
||||||
delegate?.rowNeedsUpdate(newPos)
|
} else {
|
||||||
|
delegate?.tableView.safeMoveRow(oldPos, to: newPos)
|
||||||
|
if delegate?.tableView.isFrontmost ?? false {
|
||||||
|
delegate?.rowNeedsUpdate(newPos)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user