import { Conversation } from "@/components/conversation"; import { Quote } from "@/components/quote"; import { RepostNote } from "@/components/repost"; import { TextNote } from "@/components/text"; import { ArrowRightCircleIcon, ArrowRightIcon } from "@lume/icons"; import { type ColumnRouteSearch, type Event, Kind } from "@lume/types"; import { Spinner } from "@lume/ui"; import { useInfiniteQuery } from "@tanstack/react-query"; import { Link, createFileRoute } from "@tanstack/react-router"; import { Virtualizer } from "virtua"; export const Route = createFileRoute("/global")({ validateSearch: (search: Record): ColumnRouteSearch => { return { account: search.account, label: search.label, name: search.name, }; }, beforeLoad: async ({ context }) => { const ark = context.ark; const settings = await ark.get_settings(); return { settings }; }, component: Screen, }); export function Screen() { const { account } = Route.useSearch(); const { ark } = Route.useRouteContext(); const { data, isLoading, isFetching, isFetchingNextPage, hasNextPage, fetchNextPage, } = useInfiniteQuery({ queryKey: ["global", account], initialPageParam: 0, queryFn: async ({ pageParam }: { pageParam: number }) => { const events = await ark.get_events(20, pageParam, undefined, true); return events; }, getNextPageParam: (lastPage) => { const lastEvent = lastPage?.at(-1); return lastEvent ? lastEvent.created_at - 1 : null; }, select: (data) => data?.pages.flatMap((page) => page), refetchOnWindowFocus: false, }); const renderItem = (event: Event) => { if (!event) return; switch (event.kind) { case Kind.Repost: return ; default: { const isConversation = event.tags.filter((tag) => tag[0] === "e" && tag[3] !== "mention") .length > 0; const isQuote = event.tags.filter((tag) => tag[0] === "q").length > 0; if (isConversation) { return ; } if (isQuote) { return ; } return ; } } }; return (
{isFetching && !isLoading && !isFetchingNextPage ? (
Fetching new notes...
) : null} {isLoading ? (
Loading...
) : !data.length ? ( ) : ( {data.map((item) => renderItem(item))} )} {data?.length && hasNextPage ? (
) : null}
); } function Empty() { return (

Your newsfeed is empty

Here are few suggestions to get started.

Show trending notes Discover trending users
); }