Fix load bypassing freshness

This commit is contained in:
Jon Staab
2024-09-02 15:57:40 -07:00
parent 9a5a423b3e
commit b910569fc0
8 changed files with 80 additions and 61 deletions
+5 -8
View File
@@ -5,7 +5,7 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
import {repository, load} from './core'
import {collection} from './collection'
import {ensurePlaintext} from './plaintext'
import {getWriteRelayUrls, loadRelaySelections} from './relaySelections'
import {getHintsForPubkey} from './relaySelections'
export const follows = withGetter(
deriveEventsMapped<PublishedList>(repository, {
@@ -28,13 +28,10 @@ export const {
name: "follows",
store: follows,
getKey: follows => follows.event.pubkey,
load: async (pubkey: string, hints = [], request: Partial<SubscribeRequest> = {}) => {
const relays = getWriteRelayUrls(await loadRelaySelections(pubkey, hints))
return load({
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({
...request,
relays: [...relays, ...hints],
filters: [{kinds: [FOLLOWS], authors: [pubkey]}],
})
},
relays: await getHintsForPubkey(pubkey, request.relays || []),
}),
})