update replies

This commit is contained in:
Ren Amamiya
2023-07-17 13:37:01 +07:00
parent b3b790588a
commit 5606dcb32f
11 changed files with 193 additions and 56 deletions

View File

@@ -1,17 +1,25 @@
import { NDKEvent } from '@nostr-dev-kit/ndk';
import { useQuery } from '@tanstack/react-query';
import { getReplies } from '@libs/storage';
import { useNDK } from '@libs/ndk/provider';
import { Reply } from '@shared/notes/replies/item';
export function RepliesList({ parent_id }: { parent_id: string }) {
const { status, data } = useQuery(['replies', parent_id], async () => {
return await getReplies(parent_id);
import { LumeEvent } from '@utils/types';
export function RepliesList({ id }: { id: string }) {
const { relayUrls, fetcher } = useNDK();
const { status, data } = useQuery(['thread', id], async () => {
const events = (await fetcher.fetchAllEvents(
relayUrls,
{ kinds: [1], '#e': [id] },
{ since: 0 }
)) as unknown as LumeEvent[];
return events;
});
return (
<div className="mt-5">
<div className="mt-3">
<div className="mb-2">
<h5 className="text-lg font-semibold text-zinc-300">Replies</h5>
</div>
@@ -28,7 +36,7 @@ export function RepliesList({ parent_id }: { parent_id: string }) {
</div>
) : data.length === 0 ? (
<div className="px=3">
<div className="flex w-full items-center justify-center rounded-md bg-zinc-900">
<div className="flex w-full items-center justify-center rounded-xl bg-zinc-900">
<div className="flex flex-col items-center justify-center gap-2 py-6">
<h3 className="text-3xl">👋</h3>
<p className="leading-none text-zinc-400">Share your thought on it...</p>