Skip to content

Commit

Permalink
feat: isApproximateLayout should be spawned due to pending layout j…
Browse files Browse the repository at this point in the history
…ustification
  • Loading branch information
ryuever committed Oct 7, 2023
1 parent 363b3fe commit 54360fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/data-model/src/ItemMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import noop from '@x-oasis/noop';
import defaultBooleanValue from '@x-oasis/default-boolean-value';
import ViewabilityItemMeta from './viewable/ViewabilityItemMeta';

// make itemMeta could be shared, such as data source ref change, but it's value
// not changed.
const context: {
[key: string]: ItemMeta;
} = {};
Expand Down Expand Up @@ -49,6 +51,7 @@ class ItemMeta extends ViewabilityItemMeta {
recyclerType = DEFAULT_RECYCLER_TYPE,
isInitialItem = false,
ignoredToPerBatch,
isApproximateLayout = false,
spawnProps = {},
} = props;
this._owner = owner;
Expand All @@ -64,7 +67,7 @@ class ItemMeta extends ViewabilityItemMeta {
: {};

this._canIUseRIC = canIUseRIC;
this._isApproximateLayout = false;
this._isApproximateLayout = isApproximateLayout;
this._recyclerType = recyclerType;
this._spawnProps = spawnProps;

Expand All @@ -84,6 +87,8 @@ class ItemMeta extends ViewabilityItemMeta {

return new ItemMeta({
layout,
// isApproximateLayout may cause change...
isApproximateLayout: ancestor.isApproximateLayout,
spawnProps,
...props,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/data-model/src/ListGroupDimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class ListGroupDimensions<ItemT extends {} = {}>
this._dimensionsIndexRange = this.indexKeys.reduce((acc, key) => {
const dimensions = this.getDimension(key);
const recyclerType = dimensions.recyclerType;
if (rangeMap[recyclerType] === undefined) rangeMap[recyclerType] = 0;
if (rangeMap[recyclerType] != null) rangeMap[recyclerType] = 0;

const endIndex = startIndex + dimensions.length;
const startIndexInRecycler = rangeMap[recyclerType];
Expand Down
2 changes: 2 additions & 0 deletions packages/data-model/src/types/ItemMeta.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ export type ItemMetaProps = {
spawnProps?: {
[key: string]: ItemMetaStateEventHelperProps;
};

isApproximateLayout?: boolean;
};

0 comments on commit 54360fe

Please sign in to comment.