polish
This commit is contained in:
@@ -20,7 +20,7 @@ export function useAccount() {
|
||||
staleTime: Infinity,
|
||||
refetchOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: true,
|
||||
refetchOnReconnect: false,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import { createBlock, removeBlock } from '@libs/storage';
|
||||
|
||||
interface BlockData {
|
||||
kind: number;
|
||||
title: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export function useBlock() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const add = useMutation({
|
||||
mutationFn: (data: BlockData) => {
|
||||
return createBlock(data.kind, data.title, data.content);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['blocks'] });
|
||||
},
|
||||
});
|
||||
|
||||
const remove = useMutation({
|
||||
mutationFn: (id: string) => {
|
||||
return removeBlock(id);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['blocks'] });
|
||||
},
|
||||
});
|
||||
|
||||
return { add, remove };
|
||||
}
|
||||
@@ -17,6 +17,7 @@ export function useEvent(id: string, fallback?: string) {
|
||||
} else {
|
||||
if (fallback) {
|
||||
const embed: LumeEvent = JSON.parse(fallback);
|
||||
if (embed.kind === 1) embed['content'] = parser(embed);
|
||||
embed['event_id'] = embed.id;
|
||||
await createNote(
|
||||
embed.id,
|
||||
@@ -28,22 +29,18 @@ export function useEvent(id: string, fallback?: string) {
|
||||
);
|
||||
return embed;
|
||||
} else {
|
||||
const event = await ndk.fetchEvent(id);
|
||||
const event = (await ndk.fetchEvent(id)) as unknown as LumeEvent;
|
||||
if (event) {
|
||||
await createNote(
|
||||
event.id,
|
||||
event.pubkey,
|
||||
event.kind,
|
||||
event.tags,
|
||||
event.content,
|
||||
event.content as unknown as string,
|
||||
event.created_at
|
||||
);
|
||||
event['event_id'] = event.id;
|
||||
if (event.kind === 1) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
event['content'] = parser(event);
|
||||
}
|
||||
if (event.kind === 1) event['content'] = parser(event);
|
||||
return event as unknown as LumeEvent;
|
||||
} else {
|
||||
throw new Error('Event not found');
|
||||
|
||||
@@ -47,7 +47,7 @@ export function useNostr() {
|
||||
});
|
||||
});
|
||||
|
||||
network = [...network.values()] as string[];
|
||||
network = [...lruNetwork.values()] as string[];
|
||||
} else {
|
||||
network = account.network;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export function useNostr() {
|
||||
if (network.length > 0) {
|
||||
let since: number;
|
||||
if (totalNotes === 0 || lastLogin === 0) {
|
||||
since = nHoursAgo(6);
|
||||
since = nHoursAgo(24);
|
||||
} else {
|
||||
since = lastLogin;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user