diff --git a/src/renderer/src/components/Note/index.tsx b/src/renderer/src/components/Note/index.tsx index 9d3d132..eaf8de6 100644 --- a/src/renderer/src/components/Note/index.tsx +++ b/src/renderer/src/components/Note/index.tsx @@ -48,7 +48,7 @@ export default function Note({ className="mt-2" onClick={(e) => { e.stopPropagation() - push(toNote(parentEvent.id)) + push(toNote(parentEvent)) }} /> )} diff --git a/src/renderer/src/components/NoteCard/ShortTextNoteCard.tsx b/src/renderer/src/components/NoteCard/ShortTextNoteCard.tsx index ffa8149..6e7c069 100644 --- a/src/renderer/src/components/NoteCard/ShortTextNoteCard.tsx +++ b/src/renderer/src/components/NoteCard/ShortTextNoteCard.tsx @@ -29,7 +29,7 @@ export default function ShortTextNoteCard({ className={className} onClick={(e) => { e.stopPropagation() - push(toNote(event.id)) + push(toNote(event)) }} > diff --git a/src/renderer/src/components/NotificationList/index.tsx b/src/renderer/src/components/NotificationList/index.tsx index e654514..b45d778 100644 --- a/src/renderer/src/components/NotificationList/index.tsx +++ b/src/renderer/src/components/NotificationList/index.tsx @@ -167,7 +167,7 @@ function ReplyNotification({ notification }: { notification: Event }) { return (
push(toNote(notification.id))} + onClick={() => push(toNote(notification))} > @@ -197,7 +197,7 @@ function RepostNotification({ notification }: { notification: Event }) { return (
push(toNote(event.id))} + onClick={() => push(toNote(event))} > diff --git a/src/renderer/src/lib/link.ts b/src/renderer/src/lib/link.ts index 5d7859c..a74b0d4 100644 --- a/src/renderer/src/lib/link.ts +++ b/src/renderer/src/lib/link.ts @@ -1,5 +1,11 @@ +import { Event, nip19 } from 'nostr-tools' + export const toHome = () => '/' -export const toNote = (eventId: string) => `/notes/${eventId}` +export const toNote = (eventOrId: Event | string) => { + if (typeof eventOrId === 'string') return `/notes/${eventOrId}` + const nevent = nip19.neventEncode({ id: eventOrId.id, author: eventOrId.pubkey }) + return `/notes/${nevent}` +} export const toNoteList = ({ hashtag, search, @@ -16,14 +22,20 @@ export const toNoteList = ({ if (relay) query.set('relay', relay) return `${path}?${query.toString()}` } -export const toProfile = (pubkey: string) => `/users/${pubkey}` +export const toProfile = (pubkey: string) => { + const npub = nip19.npubEncode(pubkey) + return `/users/${npub}` +} export const toProfileList = ({ search }: { search?: string }) => { const path = '/users' const query = new URLSearchParams() if (search) query.set('s', search) return `${path}?${query.toString()}` } -export const toFollowingList = (pubkey: string) => `/users/${pubkey}/following` +export const toFollowingList = (pubkey: string) => { + const npub = nip19.npubEncode(pubkey) + return `/users/${npub}/following` +} export const toRelaySettings = () => '/relay-settings' export const toNotifications = () => '/notifications' diff --git a/src/renderer/src/pages/secondary/NotePage/index.tsx b/src/renderer/src/pages/secondary/NotePage/index.tsx index 8fbc233..87d1f9d 100644 --- a/src/renderer/src/pages/secondary/NotePage/index.tsx +++ b/src/renderer/src/pages/secondary/NotePage/index.tsx @@ -53,7 +53,7 @@ function ParentNote({ eventId }: { eventId?: string }) {
push(toNote(event.id))} + onClick={() => push(toNote(event))} >