Add derivePubkeyRelays
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user