@lavalogic/scoria 0.11.14 → 0.11.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -219,7 +219,7 @@ export class TableContext {
|
|
|
219
219
|
void this.dataRepo?.data;
|
|
220
220
|
(async () => {
|
|
221
221
|
const startTime = Date.now();
|
|
222
|
-
let
|
|
222
|
+
let currentTimer;
|
|
223
223
|
const abortController = new AbortController();
|
|
224
224
|
try {
|
|
225
225
|
if (this.paginationRepo?.paginationType == PaginationType.Local) {
|
|
@@ -246,56 +246,66 @@ export class TableContext {
|
|
|
246
246
|
// console.warn(`key ${key} was already checked, new value:`, value);
|
|
247
247
|
// }
|
|
248
248
|
// });
|
|
249
|
-
|
|
250
|
-
this.filteredIndices = data.map((_, index) => index) ?? [];
|
|
251
|
-
}
|
|
252
|
-
currentTimerPromise = this.filterTimer = this.filterTimer + 1;
|
|
249
|
+
currentTimer = ++this.filterTimer;
|
|
253
250
|
await asyncSleep(150);
|
|
254
|
-
|
|
255
|
-
if (currentTimerPromise != this.filterTimer) {
|
|
251
|
+
if (currentTimer != this.filterTimer) {
|
|
256
252
|
throw new Error('stale filter');
|
|
257
253
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
254
|
+
if (!filterState.length) {
|
|
255
|
+
this.filteredIndices =
|
|
256
|
+
data.map((item, index) => {
|
|
257
|
+
if (item == null) {
|
|
258
|
+
throw new Error(`found a nullish data item at index ${index}`);
|
|
259
|
+
}
|
|
260
|
+
return index;
|
|
261
|
+
}) ?? [];
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
let settled = false;
|
|
265
|
+
const filterPromise = asyncFilterIndices(data, async (item, index) => {
|
|
266
|
+
if (item == null) {
|
|
267
|
+
throw new Error(`Found a nullish data item at async filter at index ${index}`);
|
|
270
268
|
}
|
|
269
|
+
const row = this.createRow(item, index, index);
|
|
270
|
+
return asyncAll(filterState, async (filter) => {
|
|
271
|
+
abortController.signal.throwIfAborted();
|
|
272
|
+
const def = this.columnDefsById.get(filter.id);
|
|
273
|
+
if (!def) {
|
|
274
|
+
console.warn(`Could not find column def for filter with id ${filter.id}`);
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
if (def.filterFn) {
|
|
278
|
+
return def.filterFn(row, filter.id, filter.value);
|
|
279
|
+
}
|
|
280
|
+
if (dev) {
|
|
281
|
+
console.warn(`column ${def.id} did not have a filter function`);
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
filterPromise
|
|
287
|
+
.then((indices) => {
|
|
288
|
+
this.filteredIndices = indices;
|
|
289
|
+
})
|
|
290
|
+
.catch((e) => {
|
|
271
291
|
if (dev) {
|
|
272
|
-
console.
|
|
292
|
+
console.log(`caught filter rejection:`, e);
|
|
293
|
+
console.log(`iteration ${currentTimer} cancelled after ${Date.now() - startTime}ms`);
|
|
273
294
|
}
|
|
274
|
-
|
|
295
|
+
})
|
|
296
|
+
.finally(() => {
|
|
297
|
+
settled = true;
|
|
275
298
|
});
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
})
|
|
287
|
-
.finally(() => {
|
|
288
|
-
settled = true;
|
|
289
|
-
});
|
|
290
|
-
for (;;) {
|
|
291
|
-
if (currentTimerPromise !== this.filterTimer) {
|
|
292
|
-
abortController.abort('stale data');
|
|
293
|
-
}
|
|
294
|
-
if (settled) {
|
|
295
|
-
console.log(`iteration ${await currentTimerPromise} finished ${Date.now() - startTime}ms`);
|
|
296
|
-
return;
|
|
299
|
+
for (;;) {
|
|
300
|
+
if (currentTimer !== this.filterTimer) {
|
|
301
|
+
abortController.abort('stale data');
|
|
302
|
+
}
|
|
303
|
+
if (settled) {
|
|
304
|
+
console.log(`iteration ${currentTimer} finished ${Date.now() - startTime}ms`);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
await tick();
|
|
297
308
|
}
|
|
298
|
-
await tick();
|
|
299
309
|
}
|
|
300
310
|
}
|
|
301
311
|
}
|
|
@@ -305,7 +315,7 @@ export class TableContext {
|
|
|
305
315
|
if (!message.toLocaleLowerCase().startsWith('stale')) {
|
|
306
316
|
console.error(e);
|
|
307
317
|
}
|
|
308
|
-
console.log(`iteration ${await
|
|
318
|
+
console.log(`iteration ${await currentTimer} cancelled after ${Date.now() - startTime}ms`);
|
|
309
319
|
}
|
|
310
320
|
}
|
|
311
321
|
})();
|