import { useArk } from "@lume/ark"; import { ArrowRightCircleIcon, ArrowRightIcon, LoaderIcon } from "@lume/icons"; import { Event, Kind } from "@lume/types"; import { EmptyFeed } from "@lume/ui"; import { FETCH_LIMIT } from "@lume/utils"; import { useInfiniteQuery } from "@tanstack/react-query"; import { createLazyFileRoute } from "@tanstack/react-router"; import { Virtualizer } from "virtua"; import { TextNote } from "@/components/text"; import { RepostNote } from "@/components/repost"; export const Route = createLazyFileRoute("/$account/home/local")({ component: LocalTimeline, }); function LocalTimeline() { const ark = useArk(); const { account } = Route.useParams(); const { data, hasNextPage, isLoading, isFetchingNextPage, fetchNextPage } = useInfiniteQuery({ queryKey: ["local_newsfeed", account], initialPageParam: 0, queryFn: async ({ pageParam }: { pageParam: number }) => { const events = await ark.get_events( "local", FETCH_LIMIT, pageParam, true, ); 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, }); const renderItem = (event: Event) => { if (!event) return; switch (event.kind) { case Kind.Repost: return ; default: return ; } }; return (
{isLoading ? (

Loading...

) : !data.length ? (
) : ( {data.map((item) => renderItem(item))} )}
{hasNextPage ? ( ) : null}
); }