From 9f32bb135bb18c185ba8aae2eb64253d3728f3e2 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 16 Oct 2025 18:41:18 -0500 Subject: [PATCH] Fix the whole UI blowing up when changing relays --- src/components/NostrProvider.tsx | 2 +- src/hooks/useAppSubmissions.ts | 2 +- src/hooks/useComments.ts | 2 +- src/hooks/useLoggedInAccounts.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/NostrProvider.tsx b/src/components/NostrProvider.tsx index 9a63edbc..6cf60289 100644 --- a/src/components/NostrProvider.tsx +++ b/src/components/NostrProvider.tsx @@ -31,7 +31,7 @@ const NostrProvider: React.FC = (props) => { // Update refs when config changes useEffect(() => { relayUrl.current = config.relayUrl; - queryClient.resetQueries(); + queryClient.invalidateQueries({ queryKey: ['nostr'] }); }, [config.relayUrl, queryClient]); // Initialize NPool only once diff --git a/src/hooks/useAppSubmissions.ts b/src/hooks/useAppSubmissions.ts index 937c6e53..34f74a05 100644 --- a/src/hooks/useAppSubmissions.ts +++ b/src/hooks/useAppSubmissions.ts @@ -39,7 +39,7 @@ export function useAppSubmissions() { const { nostr } = useNostr(); return useQuery({ - queryKey: ['app-submissions'], + queryKey: ['nostr', 'app-submissions'], queryFn: async (): Promise => { // Get Soapbox team follow pack for auto-approval const teamPubkeys = new Set(); diff --git a/src/hooks/useComments.ts b/src/hooks/useComments.ts index 49922c57..5fdf42be 100644 --- a/src/hooks/useComments.ts +++ b/src/hooks/useComments.ts @@ -6,7 +6,7 @@ export function useComments(root: NostrEvent | URL, limit?: number) { const { nostr } = useNostr(); return useQuery({ - queryKey: ['comments', root instanceof URL ? root.toString() : root.id, limit], + queryKey: ['nostr', 'comments', root instanceof URL ? root.toString() : root.id, limit], queryFn: async (c) => { const filter: NostrFilter = { kinds: [1111] }; diff --git a/src/hooks/useLoggedInAccounts.ts b/src/hooks/useLoggedInAccounts.ts index 22f79db4..b2a08d70 100644 --- a/src/hooks/useLoggedInAccounts.ts +++ b/src/hooks/useLoggedInAccounts.ts @@ -15,7 +15,7 @@ export function useLoggedInAccounts() { const { logins, setLogin, removeLogin } = useNostrLogin(); const { data: authors = [], isLoading } = useQuery({ - queryKey: ['logins', logins.map((l) => l.id).join(';')], + queryKey: ['nostr', 'logins', logins.map((l) => l.id).join(';')], queryFn: async ({ signal }) => { const events = await nostr.query( [{ kinds: [0], authors: logins.map((l) => l.pubkey) }],