From 28316a71c58124fe019710e006fc53575599ae22 Mon Sep 17 00:00:00 2001 From: Gigi Date: Tue, 14 Oct 2025 01:32:28 +0200 Subject: [PATCH] feat: open all profile links within app instead of external portals - Update nostrUriResolver to return internal /p/:npub links for npub/nprofile - Replace external profile links with React Router Link components - Update ResolvedMention, LargeView, and CardView components - Convert nprofile to npub before routing - Keep note/nevent links as external (no internal viewer yet) --- src/components/BookmarkViews/CardView.tsx | 13 ++++++------- src/components/BookmarkViews/LargeView.tsx | 11 +++++------ src/components/ResolvedMention.tsx | 10 ++++------ src/utils/nostrUriResolver.tsx | 10 ++++++++-- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/components/BookmarkViews/CardView.tsx b/src/components/BookmarkViews/CardView.tsx index cb802c16..39361651 100644 --- a/src/components/BookmarkViews/CardView.tsx +++ b/src/components/BookmarkViews/CardView.tsx @@ -1,4 +1,5 @@ import React, { useState } from 'react' +import { Link } from 'react-router-dom' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faBookmark, faUserLock, faChevronDown, faChevronUp, faGlobe } from '@fortawesome/free-solid-svg-icons' import { IndividualBookmark } from '../../types/bookmarks' @@ -10,7 +11,7 @@ import { IconGetter } from './shared' import { useImageCache } from '../../hooks/useImageCache' import { getPreviewImage, fetchOgImage } from '../../utils/imagePreview' import { UserSettings } from '../../services/settingsService' -import { getProfileUrl, getEventUrl } from '../../config/nostrGateways' +import { getEventUrl } from '../../config/nostrGateways' interface CardViewProps { bookmark: IndividualBookmark @@ -190,16 +191,14 @@ export const CardView: React.FC = ({
- e.stopPropagation()} > {getAuthorDisplayName()} - +
{/* CTA removed */}
diff --git a/src/components/BookmarkViews/LargeView.tsx b/src/components/BookmarkViews/LargeView.tsx index 45d84252..116b3190 100644 --- a/src/components/BookmarkViews/LargeView.tsx +++ b/src/components/BookmarkViews/LargeView.tsx @@ -1,4 +1,5 @@ import React from 'react' +import { Link } from 'react-router-dom' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { IndividualBookmark } from '../../types/bookmarks' import { formatDate } from '../../utils/bookmarkUtils' @@ -6,7 +7,7 @@ import ContentWithResolvedProfiles from '../ContentWithResolvedProfiles' import { IconGetter } from './shared' import { useImageCache } from '../../hooks/useImageCache' import { UserSettings } from '../../services/settingsService' -import { getProfileUrl, getEventUrl } from '../../config/nostrGateways' +import { getEventUrl } from '../../config/nostrGateways' interface LargeViewProps { bookmark: IndividualBookmark @@ -93,15 +94,13 @@ export const LargeView: React.FC = ({
- e.stopPropagation()} > {getAuthorDisplayName()} - + {eventNevent && ( diff --git a/src/components/ResolvedMention.tsx b/src/components/ResolvedMention.tsx index 1fa2ce77..a665149f 100644 --- a/src/components/ResolvedMention.tsx +++ b/src/components/ResolvedMention.tsx @@ -1,8 +1,8 @@ import React from 'react' +import { Link } from 'react-router-dom' 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,14 +25,12 @@ const ResolvedMention: React.FC = ({ encoded }) => { if (npub) { return ( - @{display} - + ) } diff --git a/src/utils/nostrUriResolver.tsx b/src/utils/nostrUriResolver.tsx index 13a1695e..d524a9c3 100644 --- a/src/utils/nostrUriResolver.tsx +++ b/src/utils/nostrUriResolver.tsx @@ -39,7 +39,7 @@ export function extractNaddrUris(text: string): string[] { /** * Decode a NIP-19 identifier and return a human-readable link - * For articles (naddr), returns an internal app link + * For articles (naddr) and profiles (npub/nprofile), returns internal app links * For other types, returns an external gateway link */ export function createNostrLink(encoded: string): string { @@ -51,7 +51,13 @@ export function createNostrLink(encoded: string): string { // For articles, link to our internal app route return `/a/${encoded}` case 'npub': - case 'nprofile': + // For profiles, link to our internal app route + return `/p/${encoded}` + case 'nprofile': { + // For nprofile, convert to npub and link to our internal app route + const npub = npubEncode(decoded.data.pubkey) + return `/p/${npub}` + } case 'note': case 'nevent': return getNostrUrl(encoded)