diff --git a/src/services/client.service.ts b/src/services/client.service.ts index 72ad36de..7d940e60 100644 --- a/src/services/client.service.ts +++ b/src/services/client.service.ts @@ -1198,9 +1198,12 @@ class ClientService extends EventTarget { private async fetchReplaceableEventsFromBigRelays(pubkeys: string[], kind: number) { const events = await indexedDb.getManyReplaceableEvents(pubkeys, kind) const nonExistingPubkeyIndexMap = new Map() + const existingPubkeys: string[] = [] pubkeys.forEach((pubkey, i) => { if (events[i] === undefined) { nonExistingPubkeyIndexMap.set(pubkey, i) + } else { + existingPubkeys.push(pubkey) } }) const newEvents = await this.replaceableEventFromBigRelaysDataloader.loadMany( @@ -1215,6 +1218,10 @@ class ClientService extends EventTarget { } }) + this.replaceableEventFromBigRelaysDataloader.loadMany( + existingPubkeys.map((pubkey) => ({ pubkey, kind })) + ) // update cache in background + return events } @@ -1306,6 +1313,7 @@ class ClientService extends EventTarget { private async fetchReplaceableEvent(pubkey: string, kind: number, d?: string) { const storedEvent = await indexedDb.getReplaceableEvent(pubkey, kind, d) if (storedEvent !== undefined) { + this.replaceableEventDataLoader.load({ pubkey, kind, d }) // update cache in background return storedEvent } diff --git a/src/services/indexed-db.service.ts b/src/services/indexed-db.service.ts index 18150a08..9af3f77c 100644 --- a/src/services/indexed-db.service.ts +++ b/src/services/indexed-db.service.ts @@ -497,19 +497,19 @@ class IndexedDbService { }, { name: StoreNames.RELAY_LIST_EVENTS, - expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 // 1 day + expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 * 30 // 30 day }, { name: StoreNames.FOLLOW_LIST_EVENTS, - expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 // 1 day + expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 * 30 // 30 day }, { name: StoreNames.BLOSSOM_SERVER_LIST_EVENTS, - expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 // 1 days + expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 * 30 // 30 day }, { name: StoreNames.RELAY_INFOS, - expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 // 1 days + expirationTimestamp: Date.now() - 1000 * 60 * 60 * 24 * 30 // 30 day }, { name: StoreNames.PIN_LIST_EVENTS,