diff --git a/src/loaders/comment.ts b/src/loaders/comment.ts index 829ae36..ce12d7c 100644 --- a/src/loaders/comment.ts +++ b/src/loaders/comment.ts @@ -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'