feat: add kind:1111 events to feed
This commit is contained in:
34
src/components/Note/UnknownNote.tsx
Normal file
34
src/components/Note/UnknownNote.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { getSharableEventId } from '@/lib/event'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Check, Copy } from 'lucide-react'
|
||||
import { Event } from 'nostr-tools'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
export function UnknownNote({ event, className }: { event: Event; className?: string }) {
|
||||
const { t } = useTranslation()
|
||||
const [isCopied, setIsCopied] = useState(false)
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'flex flex-col gap-2 items-center text-muted-foreground font-medium my-4',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div>{t('Cannot handle event of kind k', { k: event.kind })}</div>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
navigator.clipboard.writeText(getSharableEventId(event))
|
||||
setIsCopied(true)
|
||||
setTimeout(() => setIsCopied(false), 2000)
|
||||
}}
|
||||
variant="outline"
|
||||
>
|
||||
{isCopied ? <Check /> : <Copy />} Copy event ID
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,7 +3,8 @@ import {
|
||||
extractImageInfosFromEventTags,
|
||||
getParentEventId,
|
||||
getUsingClient,
|
||||
isPictureEvent
|
||||
isPictureEvent,
|
||||
isSupportedKind
|
||||
} from '@/lib/event'
|
||||
import { toNote } from '@/lib/link'
|
||||
import { Event, kinds } from 'nostr-tools'
|
||||
@@ -16,6 +17,7 @@ import ParentNotePreview from '../ParentNotePreview'
|
||||
import UserAvatar from '../UserAvatar'
|
||||
import Username from '../Username'
|
||||
import Highlight from './Highlight'
|
||||
import { UnknownNote } from './UnknownNote'
|
||||
|
||||
export default function Note({
|
||||
event,
|
||||
@@ -30,10 +32,7 @@ export default function Note({
|
||||
}) {
|
||||
const { push } = useSecondaryPage()
|
||||
const parentEventId = useMemo(
|
||||
() =>
|
||||
!hideParentNotePreview && event.kind === kinds.ShortTextNote
|
||||
? getParentEventId(event)
|
||||
: undefined,
|
||||
() => (hideParentNotePreview ? undefined : getParentEventId(event)),
|
||||
[event, hideParentNotePreview]
|
||||
)
|
||||
const imageInfos = useMemo(
|
||||
@@ -79,8 +78,10 @@ export default function Note({
|
||||
)}
|
||||
{event.kind === kinds.Highlights ? (
|
||||
<Highlight className="mt-2" event={event} />
|
||||
) : (
|
||||
) : isSupportedKind(event.kind) ? (
|
||||
<Content className="mt-2" event={event} />
|
||||
) : (
|
||||
<UnknownNote className="mt-2" event={event} />
|
||||
)}
|
||||
{imageInfos.length > 0 && <ImageGallery images={imageInfos} />}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user