chore: clean up

This commit is contained in:
2024-03-16 18:45:54 +07:00
parent 46cc01e0ee
commit c8e014f33e
67 changed files with 163 additions and 2723 deletions

View File

@@ -17,7 +17,7 @@
"@tanstack/react-query": "^5.28.4",
"@tanstack/react-router": "^1.20.0",
"get-urls": "^12.1.0",
"media-chrome": "^2.2.5",
"media-chrome": "^3.0.2",
"minidenticons": "^4.2.1",
"nanoid": "^5.0.6",
"qrcode.react": "^3.1.0",
@@ -28,7 +28,7 @@
"react-string-replace": "^1.1.1",
"sonner": "^1.4.3",
"string-strip-html": "^13.4.6",
"virtua": "^0.27.5"
"virtua": "^0.29.0"
},
"devDependencies": {
"@lume/tailwindcss": "workspace:^",

View File

@@ -0,0 +1,48 @@
import { useInfiniteQuery } from "@tanstack/react-query";
import { useArk } from "./useArk";
const FETCH_LIMIT = 20;
const QUERY_KEY = "local";
const DEDUP = true;
export function useEvents(key: string, account?: string) {
const ark = useArk();
const {
data,
isError,
isLoading,
isRefetching,
isFetchingNextPage,
hasNextPage,
fetchNextPage,
} = useInfiniteQuery({
queryKey: [key, account],
initialPageParam: 0,
queryFn: async ({ pageParam }: { pageParam: number }) => {
const events = await ark.get_events(
QUERY_KEY,
FETCH_LIMIT,
pageParam,
DEDUP,
);
return events;
},
getNextPageParam: (lastPage) => {
const lastEvent = lastPage?.at(-1);
if (!lastEvent) return;
return lastEvent.created_at - 1;
},
select: (data) => data?.pages.flatMap((page) => page),
refetchOnWindowFocus: false,
});
return {
data,
isError,
isLoading,
isRefetching,
isFetchingNextPage,
hasNextPage,
fetchNextPage,
};
}