From 0522e3937fc8b4d08b8df466d2a556aa56522e03 Mon Sep 17 00:00:00 2001 From: codytseng Date: Sat, 11 Jan 2025 13:20:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/providers/FeedProvider.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/providers/FeedProvider.tsx b/src/providers/FeedProvider.tsx index 09326375..7d15403a 100644 --- a/src/providers/FeedProvider.tsx +++ b/src/providers/FeedProvider.tsx @@ -43,16 +43,15 @@ export function FeedProvider({ children }: { children: React.ReactNode }) { const init = async () => { // temporary relay urls from query params const searchParams = new URLSearchParams(window.location.search) - const tempRelays = searchParams + const temporaryRelayUrls = searchParams .getAll('r') .map((url) => !url.startsWith('ws://') && !url.startsWith('wss://') ? `wss://${url}` : url ) .filter((url) => isWebsocketUrl(url)) .map((url) => normalizeUrl(url)) - if (tempRelays.length) { - setTemporaryRelayUrls(tempRelays) - return await switchFeed('temporary') + if (temporaryRelayUrls.length) { + return await switchFeed('temporary', { temporaryRelayUrls }) } if (feedType === 'following') { @@ -81,7 +80,7 @@ export function FeedProvider({ children }: { children: React.ReactNode }) { const switchFeed = async ( feedType: TFeedType, - options: { activeRelaySetId?: string | null } = {} + options: { activeRelaySetId?: string | null; temporaryRelayUrls?: string[] | null } = {} ) => { setIsReady(false) if (feedType === 'relays') { @@ -117,8 +116,10 @@ export function FeedProvider({ children }: { children: React.ReactNode }) { return } if (feedType === 'temporary') { + if (!options.temporaryRelayUrls?.length) return setFeedType(feedType) - setRelayUrls(temporaryRelayUrls) + setTemporaryRelayUrls(options.temporaryRelayUrls) + setRelayUrls(options.temporaryRelayUrls) setActiveRelaySetId(null) setFilter({}) setIsReady(true)