Remove relay selection from loaders
This commit is contained in:
@@ -5,7 +5,6 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
|
|||||||
import {repository, load} from './core'
|
import {repository, load} from './core'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
import {ensurePlaintext} from './plaintext'
|
import {ensurePlaintext} from './plaintext'
|
||||||
import {getHintsForPubkey} from './relaySelections'
|
|
||||||
|
|
||||||
export const follows = withGetter(
|
export const follows = withGetter(
|
||||||
deriveEventsMapped<PublishedList>(repository, {
|
deriveEventsMapped<PublishedList>(repository, {
|
||||||
@@ -28,10 +27,6 @@ export const {
|
|||||||
name: "follows",
|
name: "follows",
|
||||||
store: follows,
|
store: follows,
|
||||||
getKey: follows => follows.event.pubkey,
|
getKey: follows => follows.event.pubkey,
|
||||||
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||||
load({
|
load({...request, filters: [{kinds: [FOLLOWS], authors: [pubkey]}]}),
|
||||||
...request,
|
|
||||||
filters: [{kinds: [FOLLOWS], authors: [pubkey]}],
|
|
||||||
relays: await getHintsForPubkey(pubkey, request.relays || []),
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
|
|||||||
import {repository, load} from './core'
|
import {repository, load} from './core'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
import {ensurePlaintext} from './plaintext'
|
import {ensurePlaintext} from './plaintext'
|
||||||
import {getHintsForPubkey} from './relaySelections'
|
|
||||||
|
|
||||||
export const mutes = withGetter(
|
export const mutes = withGetter(
|
||||||
deriveEventsMapped<PublishedList>(repository, {
|
deriveEventsMapped<PublishedList>(repository, {
|
||||||
@@ -28,10 +27,6 @@ export const {
|
|||||||
name: "mutes",
|
name: "mutes",
|
||||||
store: mutes,
|
store: mutes,
|
||||||
getKey: mute => mute.event.pubkey,
|
getKey: mute => mute.event.pubkey,
|
||||||
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||||
load({
|
load({...request, filters: [{kinds: [MUTES], authors: [pubkey]}]}),
|
||||||
...request,
|
|
||||||
filters: [{kinds: [MUTES], authors: [pubkey]}],
|
|
||||||
relays: await getHintsForPubkey(pubkey, request.relays || []),
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
|
|||||||
import {repository, load} from './core'
|
import {repository, load} from './core'
|
||||||
import {createSearch} from './util'
|
import {createSearch} from './util'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
import {getHintsForPubkey} from './relaySelections'
|
|
||||||
|
|
||||||
export const profiles = withGetter(
|
export const profiles = withGetter(
|
||||||
deriveEventsMapped<PublishedProfile>(repository, {
|
deriveEventsMapped<PublishedProfile>(repository, {
|
||||||
@@ -24,12 +23,8 @@ export const {
|
|||||||
name: "profiles",
|
name: "profiles",
|
||||||
store: profiles,
|
store: profiles,
|
||||||
getKey: profile => profile.event.pubkey,
|
getKey: profile => profile.event.pubkey,
|
||||||
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||||
load({
|
load({...request, filters: [{kinds: [PROFILE], authors: [pubkey]}]}),
|
||||||
...request,
|
|
||||||
filters: [{kinds: [PROFILE], authors: [pubkey]}],
|
|
||||||
relays: await getHintsForPubkey(pubkey, request.relays || []),
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const profileSearch = derived(profiles, $profiles =>
|
export const profileSearch = derived(profiles, $profiles =>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import {uniq} from '@welshman/lib'
|
|
||||||
import {INBOX_RELAYS, RELAYS, getRelayTags, normalizeRelayUrl, type TrustedEvent} from '@welshman/util'
|
import {INBOX_RELAYS, RELAYS, getRelayTags, normalizeRelayUrl, type TrustedEvent} from '@welshman/util'
|
||||||
import {type SubscribeRequest} from "@welshman/net"
|
import {type SubscribeRequest} from "@welshman/net"
|
||||||
import {deriveEvents, withGetter} from '@welshman/store'
|
import {deriveEvents, withGetter} from '@welshman/store'
|
||||||
import {AppContext, load, repository} from './core'
|
import {load, repository} from './core'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
|
|
||||||
export const getRelayUrls = (event?: TrustedEvent): string[] =>
|
export const getRelayUrls = (event?: TrustedEvent): string[] =>
|
||||||
@@ -30,16 +29,9 @@ export const {
|
|||||||
store: relaySelections,
|
store: relaySelections,
|
||||||
getKey: relaySelections => relaySelections.pubkey,
|
getKey: relaySelections => relaySelections.pubkey,
|
||||||
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||||
load({
|
load({...request, filters: [{kinds: [RELAYS], authors: [pubkey]}]}),
|
||||||
...request,
|
|
||||||
filters: [{kinds: [RELAYS], authors: [pubkey]}],
|
|
||||||
relays: [...AppContext.BOOTSTRAP_RELAYS, ...request.relays || []],
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
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 inboxRelaySelections = withGetter(deriveEvents(repository, {filters: [{kinds: [RELAYS]}]}))
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
@@ -50,10 +42,6 @@ export const {
|
|||||||
name: "inboxRelaySelections",
|
name: "inboxRelaySelections",
|
||||||
store: inboxRelaySelections,
|
store: inboxRelaySelections,
|
||||||
getKey: inboxRelaySelections => inboxRelaySelections.pubkey,
|
getKey: inboxRelaySelections => inboxRelaySelections.pubkey,
|
||||||
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||||
load({
|
load({...request, filters: [{kinds: [INBOX_RELAYS], authors: [pubkey]}]}),
|
||||||
...request,
|
|
||||||
filters: [{kinds: [INBOX_RELAYS], authors: [pubkey]}],
|
|
||||||
relays: await getHintsForPubkey(pubkey, request.relays),
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user