wip: migrate frontend to new backend

This commit is contained in:
reya
2024-02-09 15:33:27 +07:00
parent ec78cf8bf7
commit 739ba63e6c
55 changed files with 351 additions and 933 deletions
+4 -24
View File
@@ -3,16 +3,15 @@ import { ArrowRightCircleIcon, LoaderIcon, SearchIcon } from "@lume/icons";
import { Event, Kind } from "@lume/types";
import { EmptyFeed } from "@lume/ui";
import { FETCH_LIMIT } from "@lume/utils";
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
import { useInfiniteQuery } from "@tanstack/react-query";
import { useEffect, useMemo, useRef } from "react";
import { Link } from "react-router-dom";
import { CacheSnapshot, VList, VListHandle } from "virtua";
export function HomeRoute({ colKey }: { colKey: string }) {
export function HomeRoute({ queryKey }: { queryKey: string }) {
const ark = useArk();
const ref = useRef<VListHandle>();
const cacheKey = `${colKey}-vlist`;
const cacheKey = `${queryKey}-vlist`;
const [offset, cache] = useMemo(() => {
const serialized = sessionStorage.getItem(cacheKey);
@@ -22,16 +21,14 @@ export function HomeRoute({ colKey }: { colKey: string }) {
const { data, hasNextPage, isLoading, isFetchingNextPage, fetchNextPage } =
useInfiniteQuery({
queryKey: [colKey],
queryKey: [queryKey],
initialPageParam: 0,
queryFn: async ({
signal,
pageParam,
}: {
signal: AbortSignal;
pageParam: number;
}) => {
const events = await ark.get_text_events(FETCH_LIMIT);
const events = await ark.get_text_events(FETCH_LIMIT, pageParam);
return events;
},
getNextPageParam: (lastPage) => {
@@ -71,23 +68,6 @@ export function HomeRoute({ colKey }: { colKey: string }) {
};
}, []);
/*
if (!ark.account.contacts.length) {
return (
<div className="px-3 mt-3">
<EmptyFeed />
<Link
to="/suggest"
className="mt-3 w-full gap-2 inline-flex items-center justify-center text-sm font-medium rounded-lg h-9 bg-blue-500 hover:bg-blue-600 text-white"
>
<SearchIcon className="size-5" />
Find accounts to follow
</Link>
</div>
);
}
*/
return (
<div className="w-full h-full">
<VList ref={ref} cache={cache} overscan={2} className="flex-1 px-3">