fix: 🐛

This commit is contained in:
codytseng
2025-08-31 01:06:28 +08:00
parent d1ac257ff9
commit b995e2150b

View File

@@ -1,9 +1,11 @@
import { useDeletedEvent } from '@/providers/DeletedEventProvider'
import { useReply } from '@/providers/ReplyProvider'
import client from '@/services/client.service'
import { Event } from 'nostr-tools'
import { useEffect, useState } from 'react'
export function useFetchEvent(eventId?: string) {
const { isEventDeleted } = useDeletedEvent()
const [isFetching, setIsFetching] = useState(true)
const { addReplies } = useReply()
const [error, setError] = useState<Error | null>(null)
@@ -20,7 +22,7 @@ export function useFetchEvent(eventId?: string) {
try {
const event = await client.fetchEvent(eventId)
if (event) {
if (event && !isEventDeleted(event)) {
setEvent(event)
addReplies([event])
}
@@ -37,5 +39,11 @@ export function useFetchEvent(eventId?: string) {
})
}, [eventId])
useEffect(() => {
if (event && isEventDeleted(event)) {
setEvent(undefined)
}
}, [isEventDeleted])
return { isFetching, error, event }
}