core: add fn to get cache item

This commit is contained in:
Ammar Ahmed
2023-12-16 11:26:33 +05:00
committed by Abdullah Atta
parent 0cab875a60
commit da68eedd64

View File

@@ -61,6 +61,19 @@ export class VirtualizedGrouping<T> {
? "header-item"
: "item";
}
cacheItem(index: number) {
const batchIndex = Math.floor(index / this.batchSize);
const batch = this.cache.get(batchIndex);
if (!batch) return;
const { items, groups, data } = batch;
const itemIndexInBatch = index - batchIndex * this.batchSize;
const group = groups?.get(itemIndexInBatch);
return {
item: items[itemIndexInBatch],
group: group && !group.hidden ? group.group : undefined,
data: data?.[itemIndexInBatch]
};
}
item(index: number): Promise<{ item: T; group?: GroupHeader }>;
item(