From 8fdf9938c2c764836901e3c1143e52abf1104167 Mon Sep 17 00:00:00 2001 From: Gigi Date: Mon, 13 Oct 2025 00:05:11 +0200 Subject: [PATCH] refactor: centralize Nostr gateway URLs in config - Create nostrGateways.ts config file with PRIMARY (njump.me) and SEARCH (search.dergigi.com) gateways - Add helper functions: getProfileUrl, getEventUrl, getNostrUrl - Update all hardcoded gateway URLs across the codebase to use the config - Updated files: HighlightItem, nostrUriResolver, BookmarkViews (Card/Large), ResolvedMention --- src/components/BookmarkViews/CardView.tsx | 5 ++-- src/components/BookmarkViews/LargeView.tsx | 5 ++-- src/components/HighlightItem.tsx | 3 +- src/components/ResolvedMention.tsx | 3 +- src/config/nostrGateways.ts | 33 ++++++++++++++++++++++ src/utils/nostrUriResolver.tsx | 9 +++--- 6 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 src/config/nostrGateways.ts diff --git a/src/components/BookmarkViews/CardView.tsx b/src/components/BookmarkViews/CardView.tsx index 975a5d96..22bb9921 100644 --- a/src/components/BookmarkViews/CardView.tsx +++ b/src/components/BookmarkViews/CardView.tsx @@ -9,6 +9,7 @@ import { classifyUrl } from '../../utils/helpers' import { IconGetter } from './shared' import { useImageCache } from '../../hooks/useImageCache' import { UserSettings } from '../../services/settingsService' +import { getProfileUrl, getEventUrl } from '../../config/nostrGateways' interface CardViewProps { bookmark: IndividualBookmark @@ -79,7 +80,7 @@ export const CardView: React.FC = ({ {eventNevent ? ( = ({
= ({
= ({ {eventNevent && ( = ({ author: highlight.pubkey, kind: 9802 }) - return `https://njump.me/${nevent}` + return getNostrUrl(nevent) } const highlightLink = getHighlightLink() diff --git a/src/components/ResolvedMention.tsx b/src/components/ResolvedMention.tsx index aac8505d..1fa2ce77 100644 --- a/src/components/ResolvedMention.tsx +++ b/src/components/ResolvedMention.tsx @@ -2,6 +2,7 @@ import React from 'react' import { useEventModel } from 'applesauce-react/hooks' import { Models, Helpers } from 'applesauce-core' import { decode, npubEncode } from 'nostr-tools/nip19' +import { getProfileUrl } from '../config/nostrGateways' const { getPubkeyFromDecodeResult } = Helpers @@ -25,7 +26,7 @@ const ResolvedMention: React.FC = ({ encoded }) => { if (npub) { return (