fix: 🐛
This commit is contained in:
parent
d1ac257ff9
commit
b995e2150b
1 changed files with 9 additions and 1 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
|
import { useDeletedEvent } from '@/providers/DeletedEventProvider'
|
||||||
import { useReply } from '@/providers/ReplyProvider'
|
import { useReply } from '@/providers/ReplyProvider'
|
||||||
import client from '@/services/client.service'
|
import client from '@/services/client.service'
|
||||||
import { Event } from 'nostr-tools'
|
import { Event } from 'nostr-tools'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
export function useFetchEvent(eventId?: string) {
|
export function useFetchEvent(eventId?: string) {
|
||||||
|
const { isEventDeleted } = useDeletedEvent()
|
||||||
const [isFetching, setIsFetching] = useState(true)
|
const [isFetching, setIsFetching] = useState(true)
|
||||||
const { addReplies } = useReply()
|
const { addReplies } = useReply()
|
||||||
const [error, setError] = useState<Error | null>(null)
|
const [error, setError] = useState<Error | null>(null)
|
||||||
|
|
@ -20,7 +22,7 @@ export function useFetchEvent(eventId?: string) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const event = await client.fetchEvent(eventId)
|
const event = await client.fetchEvent(eventId)
|
||||||
if (event) {
|
if (event && !isEventDeleted(event)) {
|
||||||
setEvent(event)
|
setEvent(event)
|
||||||
addReplies([event])
|
addReplies([event])
|
||||||
}
|
}
|
||||||
|
|
@ -37,5 +39,11 @@ export function useFetchEvent(eventId?: string) {
|
||||||
})
|
})
|
||||||
}, [eventId])
|
}, [eventId])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (event && isEventDeleted(event)) {
|
||||||
|
setEvent(undefined)
|
||||||
|
}
|
||||||
|
}, [isEventDeleted])
|
||||||
|
|
||||||
return { isFetching, error, event }
|
return { isFetching, error, event }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue