Add derivePubkeyRelays

This commit is contained in:
Jon Staab
2025-04-25 10:19:56 -07:00
parent 3636064f25
commit d14ae2ce77
2 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -1,3 +1,4 @@
import {derived} from 'svelte/store'
import {uniq, batcher, always} from "@welshman/lib"
import {
INBOX_RELAYS,
@@ -59,11 +60,16 @@ export const {
load: makeOutboxLoader(RELAYS),
})
export const getPubkeyRelays = (pubkey: string, mode?: string) =>
export const getPubkeyRelays = (pubkey: string, mode?: RelayMode) =>
mode === RelayMode.Inbox
? getRelaysFromList(inboxRelaySelectionsByPubkey.get().get(pubkey))
: getRelaysFromList(relaySelectionsByPubkey.get().get(pubkey), mode)
export const derivePubkeyRelays = (pubkey: string, mode?: RelayMode) =>
mode === RelayMode.Inbox
? derived(inboxRelaySelectionsByPubkey, $m => getRelaysFromList($m.get(pubkey)))
: derived(relaySelectionsByPubkey, $m => getRelaysFromList($m.get(pubkey), mode))
export const inboxRelaySelections = deriveEventsMapped<PublishedList>(repository, {
filters: [{kinds: [INBOX_RELAYS]}],
itemToEvent: item => item.event,
+2 -2
View File
@@ -1,7 +1,7 @@
import {parseJson, uniq, nthEq} from "@welshman/lib"
import {Address} from "./Address.js"
import {uniqTags, getRelayTags} from "./Tags.js"
import {isRelayUrl, normalizeRelayUrl} from "./Relay.js"
import {isRelayUrl, RelayMode, normalizeRelayUrl} from "./Relay.js"
import {Encryptable, DecryptedEvent} from "./Encryptable.js"
import type {EncryptableUpdates} from "./Encryptable.js"
@@ -89,7 +89,7 @@ export const addToListPrivately = (list: List, ...tags: string[][]) => {
})
}
export const getRelaysFromList = (list?: List, mode?: string): string[] => {
export const getRelaysFromList = (list?: List, mode?: RelayMode): string[] => {
let tags = getRelayTags(getListTags(list))
if (mode) {