From da2457da9fb1bdb4054db1b8c5641e6276248802 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Fri, 25 Apr 2025 10:41:38 -0700 Subject: [PATCH] Use new relay getters --- src/app/commands.ts | 8 ++++---- src/app/components/ProfileDelete.svelte | 5 +++-- src/app/requests.ts | 4 ++-- src/app/state.ts | 2 +- src/routes/+layout.svelte | 4 ++-- src/routes/settings/relays/+page.svelte | 18 +++++------------- 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/app/commands.ts b/src/app/commands.ts index 9807793e..36534de0 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -29,6 +29,8 @@ import { getRelayTagValues, toNostrURI, unionFilters, + getRelaysFromList, + RelayMode, } from "@welshman/util" import type {TrustedEvent, Filter, EventContent, EventTemplate} from "@welshman/util" import {Pool, PublishStatus, AuthStatus, SocketStatus} from "@welshman/net" @@ -42,10 +44,8 @@ import { MergedThunk, profilesByPubkey, relaySelectionsByPubkey, - getWriteRelayUrls, tagEvent, tagEventForReaction, - getRelayUrls, userRelaySelections, userInboxRelaySelections, nip44EncryptToSelf, @@ -72,7 +72,7 @@ import { export const getPubkeyHints = (pubkey: string) => { const selections = relaySelectionsByPubkey.get().get(pubkey) - const relays = selections ? getWriteRelayUrls(selections) : [] + const relays = selections ? getRelaysFromList(selections, RelayMode.Write) : [] const hints = relays.length ? relays : INDEXER_RELAYS return hints @@ -238,7 +238,7 @@ export const setInboxRelayPolicy = (url: string, enabled: boolean) => { const list = get(userInboxRelaySelections) || makeList({kind: INBOX_RELAYS}) // Only update inbox policies if they already exist or we're adding them - if (enabled || getRelayUrls(list).includes(url)) { + if (enabled || getRelaysFromList(list).includes(url)) { const tags = getRelayTags(getListTags(list)).filter(t => normalizeRelayUrl(t[1]) !== url) if (enabled) { diff --git a/src/app/components/ProfileDelete.svelte b/src/app/components/ProfileDelete.svelte index c6e81906..035e06fa 100644 --- a/src/app/components/ProfileDelete.svelte +++ b/src/app/components/ProfileDelete.svelte @@ -7,8 +7,9 @@ DELETE, isReplaceable, getAddress, + getRelaysFromList, } from "@welshman/util" - import {pubkey, userRelaySelections, publishThunk, getRelayUrls, repository} from "@welshman/app" + import {pubkey, userRelaySelections, publishThunk, repository} from "@welshman/app" import {preventDefault} from "@lib/html" import Icon from "@lib/components/Icon.svelte" import Button from "@lib/components/Button.svelte" @@ -40,7 +41,7 @@ const denominator = chunks.length + 2 const relays = uniq([ ...INDEXER_RELAYS, - ...getRelayUrls($userRelaySelections), + ...getRelaysFromList($userRelaySelections), ...getMembershipUrls($userMembership), ]) diff --git a/src/app/requests.ts b/src/app/requests.ts index 967caecf..dbcc57e2 100644 --- a/src/app/requests.ts +++ b/src/app/requests.ts @@ -25,6 +25,7 @@ import { getTagValue, getAddress, isShareableRelayUrl, + getRelaysFromList, } from "@welshman/util" import type {TrustedEvent, Filter, List} from "@welshman/util" import {feedFromFilters, makeRelayFeed, makeIntersectionFeed} from "@welshman/feeds" @@ -41,7 +42,6 @@ import { loadFollows, loadProfile, loadInboxRelaySelections, - getRelayUrls, } from "@welshman/app" import {createScroller} from "@lib/html" import {daysBetween} from "@lib/util" @@ -421,7 +421,7 @@ export const loadUserData = (pubkey: string, relays: string[] = []) => { export const discoverRelays = (lists: List[]) => Promise.all( - uniq(lists.flatMap(getRelayUrls)) + uniq(lists.flatMap($l => getRelaysFromList($l))) .filter(isShareableRelayUrl) .map(url => loadRelay(url)), ) diff --git a/src/app/state.ts b/src/app/state.ts index d8e39571..777a2414 100644 --- a/src/app/state.ts +++ b/src/app/state.ts @@ -18,6 +18,7 @@ import { always, } from "@welshman/lib" import {load} from "@welshman/net" +import {collection} from "@welshman/store" import { getIdFilters, WRAP, @@ -47,7 +48,6 @@ import {routerContext, Router} from "@welshman/router" import { pubkey, repository, - collection, profilesByPubkey, tracker, makeTrackerStore, diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index be012602..326e710d 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -19,6 +19,7 @@ FOLLOWS, PROFILE, RELAYS, + getRelaysFromList, } from "@welshman/util" import {Nip46Broker, makeSecret} from "@welshman/signer" import type {Socket} from "@welshman/net" @@ -33,7 +34,6 @@ session, signer, dropSession, - getRelayUrls, userInboxRelaySelections, loginWithNip01, loginWithNip46, @@ -204,7 +204,7 @@ {kinds: [WRAP], "#p": [$pubkey], since: ago(WEEK, 2)}, {kinds: [WRAP], "#p": [$pubkey], limit: 100}, ], - relays: getRelayUrls($userInboxRelaySelections), + relays: getRelaysFromList($userInboxRelaySelections), }) } }, diff --git a/src/routes/settings/relays/+page.svelte b/src/routes/settings/relays/+page.svelte index a807b3f9..16cbaef6 100644 --- a/src/routes/settings/relays/+page.svelte +++ b/src/routes/settings/relays/+page.svelte @@ -1,15 +1,7 @@