From 2fb6b330ae868503d51e1236a4613635148637f5 Mon Sep 17 00:00:00 2001 From: ryuever Date: Tue, 9 May 2023 14:23:15 +0800 Subject: [PATCH] fix: itemsDimensions not trigger itemMeta issue --- packages/data-model/src/ListDimensions.ts | 4 - .../src/viewable/ViewablityHelper.ts | 76 ++++++++++--------- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/packages/data-model/src/ListDimensions.ts b/packages/data-model/src/ListDimensions.ts index 32d3324b..3c7488ce 100644 --- a/packages/data-model/src/ListDimensions.ts +++ b/packages/data-model/src/ListDimensions.ts @@ -190,10 +190,6 @@ class ListDimensions extends BaseDimensions { this._offsetInListGroup = 0; - // this._onUpdateItemsMetaChangeBatchinator = new Batchinator( - // this.onUpdateItemsMetaChange.bind(this), - // 50 - // ); this.attemptToHandleEndReached(); this.handleDeps = this.handleDeps.bind(this); diff --git a/packages/data-model/src/viewable/ViewablityHelper.ts b/packages/data-model/src/viewable/ViewablityHelper.ts index ee35f36c..d31850d3 100644 --- a/packages/data-model/src/viewable/ViewablityHelper.ts +++ b/packages/data-model/src/viewable/ViewablityHelper.ts @@ -12,39 +12,39 @@ import { } from '../types'; import { isItemViewable } from './viewabilityUtils'; -const createIntervalTreeItemChangedToken = (opts: { - helper: ViewabilityItemMeta; - falsy?: boolean; - propsKey: string; -}) => { - const { helper, falsy, propsKey } = opts; - const helperMeta = {}; - // const helperMeta = helper?.getMetaOnViewableItemsChanged - // ? helper.getMetaOnViewableItemsChanged() || {} - // : {}; - return { - helper, - key: helper.getKey(), - [propsKey]: !!falsy, - ...helperMeta, - }; -}; - -const createBasicItemChangedToken = (opts: { - helper: ViewabilityItemMeta; - falsy?: boolean; - propsKey: string; -}): { - helper: ViewabilityItemMeta; - key: string; -} => { - const { helper, falsy, propsKey } = opts; - return { - helper, - key: helper.getKey(), - [propsKey]: !!falsy, - }; -}; +// const createIntervalTreeItemChangedToken = (opts: { +// helper: ViewabilityItemMeta; +// falsy?: boolean; +// propsKey: string; +// }) => { +// const { helper, falsy, propsKey } = opts; +// const helperMeta = {}; +// // const helperMeta = helper?.getMetaOnViewableItemsChanged +// // ? helper.getMetaOnViewableItemsChanged() || {} +// // : {}; +// return { +// helper, +// key: helper.getKey(), +// [propsKey]: !!falsy, +// ...helperMeta, +// }; +// }; + +// const createBasicItemChangedToken = (opts: { +// helper: ViewabilityItemMeta; +// falsy?: boolean; +// propsKey: string; +// }): { +// helper: ViewabilityItemMeta; +// key: string; +// } => { +// const { helper, falsy, propsKey } = opts; +// return { +// helper, +// key: helper.getKey(), +// [propsKey]: !!falsy, +// }; +// }; const createChangedToken = (opts: { helper: ViewabilityItemMeta; @@ -69,7 +69,7 @@ const createChangedToken = (opts: { class ViewablityHelper { readonly isListItem: boolean; private _configName: string; - private _changed: Array; + private _changed: Array = []; private _config: NormalizedViewablityConfig; private _callback: OnViewableItemsChanged; readonly _pair: ViewabilityConfigCallbackPair; @@ -317,9 +317,11 @@ class ViewablityHelper { }); }); - // for (const [itemMeta, state] of itemMetaStateMap) { - // itemMeta.setItemMetaState(state); - // } + for (const [itemMeta, state] of itemMetaStateMap) { + // @ts-ignore TODO, should reconsider. + // it only used for itemDimensions..... + itemMeta.setItemMetaState(state); + } } }