feat: display i value
This commit is contained in:
36
src/components/Note/IValue.tsx
Normal file
36
src/components/Note/IValue.tsx
Normal file
@@ -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 (
|
||||
<div className={cn('truncate text-muted-foreground', className)}>
|
||||
{t('Comment on') + ' '}
|
||||
{iValue.startsWith('http') ? (
|
||||
<a
|
||||
className="hover:text-foreground underline truncate"
|
||||
href={iValue}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{iValue}
|
||||
</a>
|
||||
) : (
|
||||
<span>{iValue}</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -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({
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<IValue event={event} className="mt-2" />
|
||||
{event.kind === kinds.Highlights ? (
|
||||
<Highlight className="mt-2" event={event} />
|
||||
) : isSupportedKind(event.kind) ? (
|
||||
|
||||
@@ -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': 'تعليق على'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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': 'にコメント'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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': 'Прокомментировать'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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': '评论于'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user