diff --git a/src/components/Note/IValue.tsx b/src/components/Note/IValue.tsx new file mode 100644 index 0000000..6df2afa --- /dev/null +++ b/src/components/Note/IValue.tsx @@ -0,0 +1,36 @@ +import { ExtendedKind } from '@/constants' +import { tagNameEquals } from '@/lib/tag' +import { cn } from '@/lib/utils' +import { Event } from 'nostr-tools' +import { useMemo } from 'react' +import { useTranslation } from 'react-i18next' + +export default function IValue({ event, className }: { event: Event; className?: string }) { + const { t } = useTranslation() + const iValue = useMemo(() => { + if (event.kind !== ExtendedKind.COMMENT) return undefined + const iTag = event.tags.find(tagNameEquals('i')) + return iTag ? iTag[1] : undefined + }, [event]) + + if (!iValue) return null + + return ( +
+ {t('Comment on') + ' '} + {iValue.startsWith('http') ? ( + e.stopPropagation()} + > + {iValue} + + ) : ( + {iValue} + )} +
+ ) +} diff --git a/src/components/Note/index.tsx b/src/components/Note/index.tsx index d124984..d2831a3 100644 --- a/src/components/Note/index.tsx +++ b/src/components/Note/index.tsx @@ -17,6 +17,7 @@ import ParentNotePreview from '../ParentNotePreview' import UserAvatar from '../UserAvatar' import Username from '../Username' import Highlight from './Highlight' +import IValue from './IValue' import { UnknownNote } from './UnknownNote' export default function Note({ @@ -76,6 +77,7 @@ export default function Note({ }} /> )} + {event.kind === kinds.Highlights ? ( ) : isSupportedKind(event.kind) ? ( diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts index 76e67c9..aea8e5c 100644 --- a/src/i18n/locales/ar.ts +++ b/src/i18n/locales/ar.ts @@ -231,6 +231,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'أنت على وشك نشر حدث موقع من قبل [{{eventAuthorName}}]. أنت حالياً مسجل الدخول كـ [{{currentUsername}}]. هل أنت متأكد؟', 'Platinum Sponsors': 'الرعاة البلاتينيون', - From: 'من' + From: 'من', + 'Comment on': 'تعليق على' } } diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index d29435e..3eab03e 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -237,6 +237,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Du bist dabei, ein Ereignis zu veröffentlichen, das von [{{eventAuthorName}}] signiert wurde. Du bist derzeit als [{{currentUsername}}] angemeldet. Bist du sicher?', 'Platinum Sponsors': 'Platin-Sponsoren', - From: 'Von' + From: 'Von', + 'Comment on': 'Kommentar zu' } } diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 407b46d..f337a81 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -231,6 +231,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?', 'Platinum Sponsors': 'Platinum Sponsors', - From: 'From' + From: 'From', + 'Comment on': 'Comment on' } } diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index f896190..d5bfe96 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -236,6 +236,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Estás a punto de publicar un evento firmado por [{{eventAuthorName}}]. Actualmente has iniciado sesión como [{{currentUsername}}]. ¿Estás seguro?', 'Platinum Sponsors': 'Patrocinadores Platino', - From: 'De' + From: 'De', + 'Comment on': 'Comentar en' } } diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 7b06433..eb642da 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -236,6 +236,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Vous êtes sur le point de publier un événement signé par [{{eventAuthorName}}]. Vous êtes actuellement connecté en tant que [{{currentUsername}}]. Êtes-vous sûr ?', 'Platinum Sponsors': 'Sponsors Platine', - From: 'De' + From: 'De', + 'Comment on': 'Commenter sur' } } diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts index 25be8d0..7b9cef3 100644 --- a/src/i18n/locales/it.ts +++ b/src/i18n/locales/it.ts @@ -235,6 +235,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Stai per pubblicare un evento firmato da [{{eventAuthorName}}]. Attualmente sei connesso come [{{currentUsername}}]. Sei sicuro?', 'Platinum Sponsors': 'Sponsor Platino', - From: 'Da' + From: 'Da', + 'Comment on': 'Commenta su' } } diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts index 42d07d0..8672293 100644 --- a/src/i18n/locales/ja.ts +++ b/src/i18n/locales/ja.ts @@ -232,6 +232,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'あなたは[{{eventAuthorName}}]によって署名されたイベントを公開しようとしています。現在[{{currentUsername}}]としてログインしています。よろしいですか?', 'Platinum Sponsors': 'プラチナスポンサー', - From: 'から' + From: 'から', + 'Comment on': 'にコメント' } } diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index 263a6b1..47f16a7 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -234,6 +234,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Zaraz opublikujesz zdarzenie podpisane przez [{{eventAuthorName}}]. Obecnie jesteś zalogowany jako [{{currentUsername}}]. Czy jesteś pewien?', 'Platinum Sponsors': 'Sponsorzy Platynowi', - From: 'Od' + From: 'Od', + 'Comment on': 'Komentarz do' } } diff --git a/src/i18n/locales/pt-BR.ts b/src/i18n/locales/pt-BR.ts index 530d4e4..e14e3b6 100644 --- a/src/i18n/locales/pt-BR.ts +++ b/src/i18n/locales/pt-BR.ts @@ -234,6 +234,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Você está prestes a publicar um evento assinado por [{{eventAuthorName}}]. Você está atualmente logado como [{{currentUsername}}]. Tem certeza?', 'Platinum Sponsors': 'Patrocinadores Platinum', - From: 'De' + From: 'De', + 'Comment on': 'Comentar em' } } diff --git a/src/i18n/locales/pt-PT.ts b/src/i18n/locales/pt-PT.ts index 54f5764..a46b697 100644 --- a/src/i18n/locales/pt-PT.ts +++ b/src/i18n/locales/pt-PT.ts @@ -235,6 +235,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Você está prestes a publicar um evento assinado por [{{eventAuthorName}}]. Você está atualmente logado como [{{currentUsername}}]. Tem certeza?', 'Platinum Sponsors': 'Patrocinadores Platinum', - From: 'De' + From: 'De', + 'Comment on': 'Comentar em' } } diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index 2ba9526..8f2e877 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -235,6 +235,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': 'Вы собираетесь опубликовать событие, подписанное [{{eventAuthorName}}]. Вы в данный момент вошли как [{{currentUsername}}]. Вы уверены?', 'Platinum Sponsors': 'Платиновые спонсоры', - From: 'От' + From: 'От', + 'Comment on': 'Прокомментировать' } } diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index eb33e57..28650b0 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -232,6 +232,7 @@ export default { 'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?': '您即将发布一条由 [{{eventAuthorName}}] 签名的事件。您当前以 [{{currentUsername}}] 登录。确定吗?', 'Platinum Sponsors': '白金赞助商', - From: '来自' + From: '来自', + 'Comment on': '评论于' } } diff --git a/src/lib/event.ts b/src/lib/event.ts index e3a4686..02c2150 100644 --- a/src/lib/event.ts +++ b/src/lib/event.ts @@ -26,7 +26,9 @@ export function isNsfwEvent(event: Event) { } export function isReplyNoteEvent(event: Event) { - if (event.kind === ExtendedKind.COMMENT) return true + if (event.kind === ExtendedKind.COMMENT) { + return !!getParentEventTag(event) + } if (event.kind !== kinds.ShortTextNote) return false const cache = EVENT_IS_REPLY_NOTE_CACHE.get(event.id)