A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: simplify item key derivation in virtualized grouping
Abdullah Attaf57c7b599805
diff --git a/packages/core/src/utils/virtualized-grouping.ts b/packages/core/src/utils/virtualized-grouping.tsindex f5672e9c6..d28733df1 100644--- a/packages/core/src/utils/virtualized-grouping.ts+++ b/packages/core/src/utils/virtualized-grouping.ts@@ -49,18 +49,7 @@ export class VirtualizedGrouping<T> {}getKey(index: number) {- const batchIndex = Math.floor(index / this.batchSize);- const batch = this.cache.get(batchIndex);- if (!batch) return `${index}`;-- const { items, groups } = batch;- const itemIndexInBatch = index - batchIndex * this.batchSize;- const group = groups?.find(- (f) => f.index === itemIndexInBatch && !f.hidden- );- return group- ? group.group.id- : (items[itemIndexInBatch] as any)?.id || `${index}`;+ return `${index}`;}item(index: number): Promise<{ item: T; group?: GroupHeader }>;@@ -147,18 +136,10 @@ export class VirtualizedGrouping<T> {private loadBatch(batch: number, operate?: BatchOperator<T>) {if (this.pending.has(batch)) return this.pending.get(batch)!;- if (!this.isLastBatch(batch)) clearTimeout(this.loadBatchTimeout);- return new Promise<Batch<T>>((resolve, reject) => {- this.loadBatchTimeout = setTimeout(() => {- const promise = this.load(batch, operate);- this.pending.set(batch, promise);- return promise- .then(resolve)- .catch(reject)- .finally(() => {- this.pending.delete(batch);- });- }, 16) as unknown as number;+ const promise = this.load(batch, operate);+ this.pending.set(batch, promise);+ return promise.finally(() => {+ this.pending.delete(batch);});}