Do not break onListChanged

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-08-15 20:48:51 +05:30 committed by Bruno Windels
parent 5d54285640
commit 33ac34b04e

View file

@ -162,6 +162,7 @@ export class LazyListView extends ListView {
onAdd(idx, value) {
const {topCount, renderCount, bottomCount} = this._renderRange;
if (this._renderRange.containsIndex(idx)) {
this.onBeforeListChanged();
const normalizedIdx = this._renderRange.normalize(idx);
if (bottomCount === 0) {
/*
@ -179,7 +180,8 @@ export class LazyListView extends ListView {
this._removeChild(this._childInstances.pop());
this._renderRange = new ItemRange(topCount, renderCount, bottomCount + 1);
}
super.onAdd(normalizedIdx, value);
super.onAdd(normalizedIdx, value, true);
this.onListChanged();
}
else {
this._renderRange = idx < topCount ? new ItemRange(topCount + 1, renderCount, bottomCount):
@ -191,8 +193,9 @@ export class LazyListView extends ListView {
onRemove(idx, value) {
const {topCount, renderCount, bottomCount} = this._renderRange;
if (this._renderRange.containsIndex(idx)) {
this.onBeforeListChanged();
const normalizedIdx = this._renderRange.normalize(idx);
super.onRemove(normalizedIdx, value);
super.onRemove(normalizedIdx, value, true);
if (bottomCount === 0) {
// See onAdd for explanation
this._renderRange = new ItemRange(topCount, renderCount - 1, bottomCount);
@ -203,6 +206,7 @@ export class LazyListView extends ListView {
this._root.appendChild(mountView(child, this._mountArgs));
this._renderRange = new ItemRange(topCount, renderCount, bottomCount - 1);
}
this.onListChanged();
}
else {
this._renderRange = idx < topCount ? new ItemRange(topCount - 1, renderCount, bottomCount):