Remove relay selection from loaders

This commit is contained in:
Jon Staab
2024-09-03 09:35:13 -07:00
parent 606de1fe4a
commit d2dd7544fa
4 changed files with 10 additions and 37 deletions
+2 -7
View File
@@ -5,7 +5,6 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
import {repository, load} from './core'
import {collection} from './collection'
import {ensurePlaintext} from './plaintext'
import {getHintsForPubkey} from './relaySelections'
export const follows = withGetter(
deriveEventsMapped<PublishedList>(repository, {
@@ -28,10 +27,6 @@ export const {
name: "follows",
store: follows,
getKey: follows => follows.event.pubkey,
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({
...request,
filters: [{kinds: [FOLLOWS], authors: [pubkey]}],
relays: await getHintsForPubkey(pubkey, request.relays || []),
}),
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({...request, filters: [{kinds: [FOLLOWS], authors: [pubkey]}]}),
})
+2 -7
View File
@@ -5,7 +5,6 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
import {repository, load} from './core'
import {collection} from './collection'
import {ensurePlaintext} from './plaintext'
import {getHintsForPubkey} from './relaySelections'
export const mutes = withGetter(
deriveEventsMapped<PublishedList>(repository, {
@@ -28,10 +27,6 @@ export const {
name: "mutes",
store: mutes,
getKey: mute => mute.event.pubkey,
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({
...request,
filters: [{kinds: [MUTES], authors: [pubkey]}],
relays: await getHintsForPubkey(pubkey, request.relays || []),
}),
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({...request, filters: [{kinds: [MUTES], authors: [pubkey]}]}),
})
+2 -7
View File
@@ -6,7 +6,6 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
import {repository, load} from './core'
import {createSearch} from './util'
import {collection} from './collection'
import {getHintsForPubkey} from './relaySelections'
export const profiles = withGetter(
deriveEventsMapped<PublishedProfile>(repository, {
@@ -24,12 +23,8 @@ export const {
name: "profiles",
store: profiles,
getKey: profile => profile.event.pubkey,
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({
...request,
filters: [{kinds: [PROFILE], authors: [pubkey]}],
relays: await getHintsForPubkey(pubkey, request.relays || []),
}),
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({...request, filters: [{kinds: [PROFILE], authors: [pubkey]}]}),
})
export const profileSearch = derived(profiles, $profiles =>
+4 -16
View File
@@ -1,8 +1,7 @@
import {uniq} from '@welshman/lib'
import {INBOX_RELAYS, RELAYS, getRelayTags, normalizeRelayUrl, type TrustedEvent} from '@welshman/util'
import {type SubscribeRequest} from "@welshman/net"
import {deriveEvents, withGetter} from '@welshman/store'
import {AppContext, load, repository} from './core'
import {load, repository} from './core'
import {collection} from './collection'
export const getRelayUrls = (event?: TrustedEvent): string[] =>
@@ -30,16 +29,9 @@ export const {
store: relaySelections,
getKey: relaySelections => relaySelections.pubkey,
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({
...request,
filters: [{kinds: [RELAYS], authors: [pubkey]}],
relays: [...AppContext.BOOTSTRAP_RELAYS, ...request.relays || []],
}),
load({...request, filters: [{kinds: [RELAYS], authors: [pubkey]}]}),
})
export const getHintsForPubkey = async (pubkey: string, relays: string[] = []) =>
uniq([...relays, ...AppContext.BOOTSTRAP_RELAYS, ...getWriteRelayUrls(await loadRelaySelections(pubkey, {relays}))])
export const inboxRelaySelections = withGetter(deriveEvents(repository, {filters: [{kinds: [RELAYS]}]}))
export const {
@@ -50,10 +42,6 @@ export const {
name: "inboxRelaySelections",
store: inboxRelaySelections,
getKey: inboxRelaySelections => inboxRelaySelections.pubkey,
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({
...request,
filters: [{kinds: [INBOX_RELAYS], authors: [pubkey]}],
relays: await getHintsForPubkey(pubkey, request.relays),
}),
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
load({...request, filters: [{kinds: [INBOX_RELAYS], authors: [pubkey]}]}),
})