refactor: remove electron-related code
This commit is contained in:
parent
bed8df06e8
commit
2b1e6fe8f5
200 changed files with 2771 additions and 8432 deletions
23
src/components/NoteCard/RepostNoteCard.tsx
Normal file
23
src/components/NoteCard/RepostNoteCard.tsx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import client from '@/services/client.service'
|
||||
import { Event, kinds, verifyEvent } from 'nostr-tools'
|
||||
import { useMemo } from 'react'
|
||||
import ShortTextNoteCard from './ShortTextNoteCard'
|
||||
|
||||
export default function RepostNoteCard({ event, className }: { event: Event; className?: string }) {
|
||||
const targetEvent = useMemo(() => {
|
||||
const targetEvent = event.content ? (JSON.parse(event.content) as Event) : null
|
||||
try {
|
||||
if (!targetEvent || !verifyEvent(targetEvent) || targetEvent.kind !== kinds.ShortTextNote) {
|
||||
return null
|
||||
}
|
||||
client.addEventToCache(targetEvent)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
||||
return targetEvent
|
||||
}, [event])
|
||||
if (!targetEvent) return null
|
||||
|
||||
return <ShortTextNoteCard className={className} reposter={event.pubkey} event={targetEvent} />
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue