feat: use negentropy as much as possible

This commit is contained in:
2024-10-08 10:36:31 +07:00
parent 8c6aea8050
commit d2b5ae0507
12 changed files with 202 additions and 209 deletions

View File

@@ -4,11 +4,22 @@ import { useQuery } from "@tanstack/react-query";
import { nip19 } from "nostr-tools";
import { LumeEvent } from "../event";
export function useEvent(id: string) {
export function useEvent(id: string, repost?: string) {
const { isLoading, isError, error, data } = useQuery({
queryKey: ["event", id],
queryFn: async () => {
try {
if (repost?.length) {
const nostrEvent: NostrEvent = JSON.parse(repost);
const res = await commands.getEventMeta(nostrEvent.content);
if (res.status === "ok") {
nostrEvent.meta = res.data;
}
return new LumeEvent(nostrEvent);
}
// Validate ID
let normalizeId: string = id
.replace("nostr:", "")