Publish to preset relays

This commit is contained in:
Alex Gleason 2025-06-04 11:32:12 -05:00
parent 696c5ba963
commit cd87b6e430
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

View File

@ -10,7 +10,7 @@ interface NostrProviderProps {
const NostrProvider: React.FC<NostrProviderProps> = (props) => { const NostrProvider: React.FC<NostrProviderProps> = (props) => {
const { children } = props; const { children } = props;
const { config } = useAppContext(); const { config, presetRelays } = useAppContext();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -36,7 +36,19 @@ const NostrProvider: React.FC<NostrProviderProps> = (props) => {
return new Map([[relayUrl.current, filters]]); return new Map([[relayUrl.current, filters]]);
}, },
eventRouter(_event: NostrEvent) { eventRouter(_event: NostrEvent) {
return [relayUrl.current]; // Publish to the selected relay
const allRelays = new Set<string>([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];
}, },
}); });
} }