From d5724fbdf2c8e14aa7f3812e44bc1fae2aa55810 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 6 Jan 2026 11:28:44 -0800 Subject: [PATCH] remove fetch relay via dufflepud --- packages/app/src/relays.ts | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/packages/app/src/relays.ts b/packages/app/src/relays.ts index ae31444..40c0041 100644 --- a/packages/app/src/relays.ts +++ b/packages/app/src/relays.ts @@ -1,9 +1,8 @@ import {writable, derived, Subscriber} from "svelte/store" -import {batcher, fetchJson, postJson, Maybe, noop} from "@welshman/lib" +import {fetchJson, Maybe} from "@welshman/lib" import {RelayProfile} from "@welshman/util" import {displayRelayUrl, displayRelayProfile} from "@welshman/util" import {getter, deriveItems, makeForceLoadItem, makeLoadItem, makeDeriveItem} from "@welshman/store" -import {appContext} from "./context.js" export const relaysByUrl = writable(new Map()) @@ -29,7 +28,7 @@ export const onRelay = (sub: (relay: RelayProfile) => void) => { ) } -export const fetchRelayDirectly = async (url: string): Promise> => { +export const fetchRelay = async (url: string): Promise> => { try { const json = await fetchJson(url.replace(/^ws/, "http"), { headers: { @@ -55,39 +54,6 @@ export const fetchRelayDirectly = async (url: string): Promise { - // Handle a race condition edge case where dufflepud url changes under us - if (!appContext.dufflepudUrl) { - return urls.map(noop) - } - - const res: any = await postJson(`${appContext.dufflepudUrl}/relay/info`, {urls}) - const result = new Map() - - for (const {url, info} of res?.data || []) { - if (info) { - result.set(url, {...info, url}) - } - } - - relaysByUrl.update($relaysByUrl => { - for (const [url, info] of result) { - $relaysByUrl.set(url, info) - } - - return $relaysByUrl - }) - - for (const info of result.values()) { - notifyRelay(info) - } - - return urls.map(url => result.get(url)) -}) - -export const fetchRelay = (url: string) => - appContext.dufflepudUrl ? fetchRelayUsingProxy(url) : fetchRelayDirectly(url) - export const forceLoadRelay = makeForceLoadItem(fetchRelay, getRelay) export const loadRelay = makeLoadItem(fetchRelay, getRelay)