diff --git a/src/routes/feeds.tsx b/src/routes/feeds.tsx --- a/src/routes/feeds.tsx +++ b/src/routes/feeds.tsx @@ -1,12 +1,52 @@ -import { createFileRoute } from "@tanstack/react-router"; +import * as ATPAPI from "@atproto/api"; +import { createFileRoute, Link } from "@tanstack/react-router"; +import { useAtom } from "jotai"; +import * as React from "react"; import { Header } from "~/components/Header"; +import { useAuth } from "~/providers/UnifiedAuthProvider"; +import { imgCDNAtom, quickAuthAtom } from "~/utils/atoms"; +import { + useQueryArbitrary, + useQueryIdentity, + useQueryPreferences, +} from "~/utils/useQuery"; export const Route = createFileRoute("/feeds")({ component: Feeds, }); export function Feeds() { + const { agent, status } = useAuth(); + const [quickAuth] = useAtom(quickAuthAtom); + const isAuthRestoring = quickAuth ? status === "loading" : false; + + const identityresultmaybe = useQueryIdentity( + !isAuthRestoring ? agent?.did : undefined, + ); + const identity = identityresultmaybe?.data; + + const prefsresultmaybe = useQueryPreferences({ + agent: !isAuthRestoring ? (agent ?? undefined) : undefined, + pdsUrl: !isAuthRestoring ? identity?.pds : undefined, + }); + const prefs = prefsresultmaybe?.data; + + const savedFeeds = React.useMemo(() => { + const savedFeedsPref = prefs?.preferences?.find( + (p: any) => p?.$type === "app.bsky.actor.defs#savedFeedsPrefV2", + ); + return savedFeedsPref?.items || []; + }, [prefs]); + + const pinnedFeeds = React.useMemo(() => { + return savedFeeds.filter((feed: any) => feed.pinned); + }, [savedFeeds]); + + const nonPinnedFeeds = React.useMemo(() => { + return savedFeeds.filter((feed: any) => !feed.pinned); + }, [savedFeeds]); + return (
No feeds saved yet.
++ Save feeds from the home page to see them here. +
++ {feedUri === "following" ? "(not implemented, if clicked will open an alternative)" : feed?.description || "No description"} +
+