From cd87b6e4300de379aa67c86577b1d92d16618590 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 4 Jun 2025 11:32:12 -0500 Subject: [PATCH] Publish to preset relays --- src/components/NostrProvider.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/NostrProvider.tsx b/src/components/NostrProvider.tsx index 978d3fa..6d74597 100644 --- a/src/components/NostrProvider.tsx +++ b/src/components/NostrProvider.tsx @@ -10,7 +10,7 @@ interface NostrProviderProps { const NostrProvider: React.FC = (props) => { const { children } = props; - const { config } = useAppContext(); + const { config, presetRelays } = useAppContext(); const queryClient = useQueryClient(); @@ -36,7 +36,19 @@ const NostrProvider: React.FC = (props) => { return new Map([[relayUrl.current, filters]]); }, eventRouter(_event: NostrEvent) { - return [relayUrl.current]; + // Publish to the selected relay + const allRelays = new Set([relayUrl.current]); + + // Also publish to the preset relays, capped to 5 + for (const { url } of (presetRelays ?? [])) { + allRelays.add(url); + + if (allRelays.size >= 5) { + break; + } + } + + return [...allRelays]; }, }); }