refactor: prevent duplicate preload

This commit is contained in:
Kieran 2024-01-08 11:33:04 +00:00
parent a54924f339
commit 08241bbbf6
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -42,9 +42,12 @@ export abstract class FeedCache<TCached> {
}
async preload() {
// assume already preloaded if keys exist on table in memory
if (this.onTable.size === 0) {
const keys = (await this.table?.toCollection().primaryKeys()) ?? [];
this.onTable = new Set<string>(keys.map(a => a as string));
}
}
keysOnTable() {
return [...this.onTable];