Fix adv.comments issues #209
@ -1,4 +1,8 @@
|
||||
import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk'
|
||||
import {
|
||||
NDKEvent,
|
||||
NDKKind,
|
||||
NDKSubscriptionCacheUsage
|
||||
} from '@nostr-dev-kit/ndk'
|
||||
import { NDKContextType } from 'contexts/NDKContext'
|
||||
import { LoaderFunctionArgs, redirect } from 'react-router-dom'
|
||||
import { CommentsLoaderResult } from 'types/comments'
|
||||
@ -24,10 +28,15 @@ export const commentsLoader =
|
||||
const replies: NDKEvent[] = []
|
||||
let eTag: string | undefined = replyEvent.tagValue('e')
|
||||
while (eTag) {
|
||||
const prev = await ndkContext.ndk.fetchEvent({
|
||||
kinds: [NDKKind.Text, NDKKind.GenericReply],
|
||||
ids: [eTag]
|
||||
})
|
||||
const prev = await ndkContext.ndk.fetchEvent(
|
||||
{
|
||||
kinds: [NDKKind.Text, NDKKind.GenericReply],
|
||||
ids: [eTag]
|
||||
},
|
||||
{
|
||||
cacheUsage: NDKSubscriptionCacheUsage.CACHE_FIRST
|
||||
}
|
||||
)
|
||||
if (prev) {
|
||||
replies.push(prev)
|
||||
eTag = prev.tagValue('e')
|
||||
@ -39,6 +48,7 @@ export const commentsLoader =
|
||||
event: replyEvent,
|
||||
parents: replies
|
||||
}
|
||||
console.log(replyEvent.content)
|
||||
return result
|
||||
} catch (error) {
|
||||
let message = 'An error occurred in fetching comment from relays'
|
||||
|
Loading…
x
Reference in New Issue
Block a user