From e46f09427b02b4121b30dbbc61feb1d07ae5368b Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 24 Mar 2020 16:13:59 +0800 Subject: [PATCH] feat:fix when continious reset list,then getBatchedItems will continious call twice --- doric-js/src/widget/list.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doric-js/src/widget/list.ts b/doric-js/src/widget/list.ts index 8b94b6c7..e148c208 100644 --- a/doric-js/src/widget/list.ts +++ b/doric-js/src/widget/list.ts @@ -89,12 +89,9 @@ export class List extends Superview implements IList { this.itemCount = 0 } private getItem(itemIdx: number) { - let view = this.cachedViews.get(`${itemIdx}`) - if (view === undefined) { - view = this.renderItem(itemIdx) - view.superview = this - this.cachedViews.set(`${itemIdx}`, view) - } + let view = this.renderItem(itemIdx) + view.superview = this + this.cachedViews.set(`${itemIdx}`, view) return view } @@ -108,7 +105,7 @@ export class List extends Superview implements IList { } private renderBunchedItems(start: number, length: number) { - this.ignoreDirtyCallOnce = true; + this.ignoreDirtyCallOnce = true return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { const listItem = this.getItem(start + idx) return listItem.toModel()