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>
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
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'
|
||||
import { FormattedTimestamp } from '../FormattedTimestamp'
|
||||
import { UnknownNote } from '../Note/UnknownNote'
|
||||
import UserAvatar from '../UserAvatar'
|
||||
import Username from '../Username'
|
||||
import RepostDescription from './RepostDescription'
|
||||
@@ -22,9 +18,6 @@ export default function UnknownNoteCard({
|
||||
embedded?: boolean
|
||||
reposter?: string
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const [isCopied, setIsCopied] = useState(false)
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div className={cn(embedded ? 'p-2 sm:p-3 border rounded-lg' : 'px-4 py-3')}>
|
||||
@@ -44,20 +37,7 @@ export default function UnknownNoteCard({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2 items-center text-muted-foreground font-medium my-4">
|
||||
<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>
|
||||
<UnknownNote event={event} />
|
||||
</div>
|
||||
{!embedded && <Separator />}
|
||||
</div>
|
||||
|
||||
@@ -110,7 +110,7 @@ export default function NoteList({
|
||||
subRequests.push({
|
||||
urls: myRelayList.write.concat(BIG_RELAY_URLS).slice(0, 5),
|
||||
filter: {
|
||||
kinds: [kinds.ShortTextNote, kinds.Repost, kinds.Highlights],
|
||||
kinds: [kinds.ShortTextNote, kinds.Repost, kinds.Highlights, ExtendedKind.COMMENT],
|
||||
authors: [pubkey],
|
||||
'#p': [author],
|
||||
limit: LIMIT
|
||||
@@ -119,7 +119,7 @@ export default function NoteList({
|
||||
subRequests.push({
|
||||
urls: targetRelayList.write.concat(BIG_RELAY_URLS).slice(0, 5),
|
||||
filter: {
|
||||
kinds: [kinds.ShortTextNote, kinds.Repost, kinds.Highlights],
|
||||
kinds: [kinds.ShortTextNote, kinds.Repost, kinds.Highlights, ExtendedKind.COMMENT],
|
||||
authors: [author],
|
||||
'#p': [pubkey],
|
||||
limit: LIMIT
|
||||
@@ -135,7 +135,7 @@ export default function NoteList({
|
||||
kinds:
|
||||
filterType === 'pictures'
|
||||
? [ExtendedKind.PICTURE]
|
||||
: [kinds.ShortTextNote, kinds.Repost, kinds.Highlights],
|
||||
: [kinds.ShortTextNote, kinds.Repost, kinds.Highlights, ExtendedKind.COMMENT],
|
||||
limit: areAlgoRelays ? ALGO_LIMIT : LIMIT
|
||||
}
|
||||
if (relayUrls.length === 0 && (_filter.authors?.length || author)) {
|
||||
|
||||
@@ -61,7 +61,12 @@ export function isProtectedEvent(event: Event) {
|
||||
}
|
||||
|
||||
export function isSupportedKind(kind: number) {
|
||||
return [kinds.ShortTextNote, kinds.Highlights, ExtendedKind.PICTURE].includes(kind)
|
||||
return [
|
||||
kinds.ShortTextNote,
|
||||
kinds.Highlights,
|
||||
ExtendedKind.PICTURE,
|
||||
ExtendedKind.COMMENT
|
||||
].includes(kind)
|
||||
}
|
||||
|
||||
export function getParentEventTag(event?: Event) {
|
||||
|
||||
Reference in New Issue
Block a user