add note replies model

This commit is contained in:
Ren Amamiya
2023-06-19 15:41:50 +07:00
parent ad51971239
commit aa8531b32b
7 changed files with 37 additions and 78 deletions

View File

@@ -25,13 +25,13 @@ const fetcher = async ([, ndk, id]) => {
case 1:
replies += 1;
createReplyNote(
id,
event.id,
event.pubkey,
event.kind,
event.tags,
event.content,
event.created_at,
id,
);
break;
case 6:

View File

@@ -1,22 +1,13 @@
import { NDKEvent, NDKFilter } from "@nostr-dev-kit/ndk";
import { getReplies } from "@libs/storage";
import { NDKEvent } from "@nostr-dev-kit/ndk";
import { EmptyIcon } from "@shared/icons";
import { Reply } from "@shared/notes/replies/item";
import { RelayContext } from "@shared/relayProvider";
import { useContext } from "react";
import useSWR from "swr";
const fetcher = async ([, ndk, id]) => {
const filter: NDKFilter = {
"#e": [id],
kinds: [1],
};
const events = await ndk.fetchEvents(filter);
return [...events];
};
const fetcher = ([, id]) => getReplies(id);
export function RepliesList({ id }: { id: string }) {
const ndk = useContext(RelayContext);
const { data } = useSWR(["note-replies", ndk, id], fetcher);
export function RepliesList({ parent_id }: { parent_id: string }) {
const { data }: any = useSWR(["note-replies", parent_id], fetcher);
return (
<div className="mt-5">