Fix load bypassing freshness
This commit is contained in:
@@ -2,17 +2,19 @@ import {derived} from 'svelte/store'
|
||||
import {readProfile, displayProfile, displayPubkey, PROFILE} from '@welshman/util'
|
||||
import {type SubscribeRequest} from "@welshman/net"
|
||||
import {type PublishedProfile} from "@welshman/util"
|
||||
import {deriveEventsMapped} from '@welshman/store'
|
||||
import {deriveEventsMapped, withGetter} from '@welshman/store'
|
||||
import {repository, load} from './core'
|
||||
import {createSearch} from './util'
|
||||
import {collection} from './collection'
|
||||
import {getWriteRelayUrls, loadRelaySelections} from './relaySelections'
|
||||
import {getHintsForPubkey} from './relaySelections'
|
||||
|
||||
export const profiles = deriveEventsMapped<PublishedProfile>(repository, {
|
||||
filters: [{kinds: [PROFILE]}],
|
||||
eventToItem: readProfile,
|
||||
itemToEvent: item => item.event,
|
||||
})
|
||||
export const profiles = withGetter(
|
||||
deriveEventsMapped<PublishedProfile>(repository, {
|
||||
filters: [{kinds: [PROFILE]}],
|
||||
eventToItem: readProfile,
|
||||
itemToEvent: item => item.event,
|
||||
})
|
||||
)
|
||||
|
||||
export const {
|
||||
indexStore: profilesByPubkey,
|
||||
@@ -22,15 +24,12 @@ export const {
|
||||
name: "profiles",
|
||||
store: profiles,
|
||||
getKey: profile => profile.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: [PROFILE], authors: [pubkey]}],
|
||||
})
|
||||
},
|
||||
relays: await getHintsForPubkey(pubkey, request.relays || []),
|
||||
}),
|
||||
})
|
||||
|
||||
export const profileSearch = derived(profiles, $profiles =>
|
||||
|
||||
Reference in New Issue
Block a user