/// // dont forget to run this // npx @tanstack/router-cli generate import type { QueryClient } from "@tanstack/react-query"; import { createRootRouteWithContext, Link, Outlet, Scripts, useLocation, useNavigate, } from "@tanstack/react-router"; import { TanStackRouterDevtools } from "@tanstack/react-router-devtools"; import { type SVGProps,useState } from "react"; import * as React from "react"; import { DefaultCatchBoundary } from "~/components/DefaultCatchBoundary"; import Login from "~/components/Login"; import { NotFound } from "~/components/NotFound"; import { UnifiedAuthProvider, useAuth } from "~/providers/UnifiedAuthProvider"; import { seo } from "~/utils/seo"; export const Route = createRootRouteWithContext<{ queryClient: QueryClient; }>()({ head: () => ({ meta: [ { charSet: "utf-8", }, { name: "viewport", content: "width=device-width, initial-scale=1", }, ...seo({ title: "Red Dwarf", description: `Distributed Bluesky Client`, }), ], links: [ { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png", }, { rel: "icon", type: "image/png", sizes: "32x32", href: "/redstar.png?whatwg", }, { rel: "icon", type: "image/png", sizes: "16x16", href: "/redstar.png?whatwg", }, { rel: "manifest", href: "/site.webmanifest", color: "#fffff" }, { rel: "icon", href: "/favicon.ico" }, ], }), errorComponent: import.meta.env.DEV ? undefined : (props) => ( ), notFoundComponent: () => , component: RootComponent, }); function RootComponent() { return ( ); } function RootDocument({ children }: { children: React.ReactNode }) { const location = useLocation(); const navigate = useNavigate(); const { agent } = useAuth(); const authed = !!agent?.did; const isHome = location.pathname === "/"; const isNotifications = location.pathname.startsWith("/notifications"); const isProfile = agent && ((location.pathname === (`/profile/${agent?.did}`)) || (location.pathname === (`/profile/${encodeURIComponent(agent?.did??"")}`))); const [postOpen, setPostOpen] = useState(false); const [postText, setPostText] = useState(""); const [posting, setPosting] = useState(false); const [postSuccess, setPostSuccess] = useState(false); const [postError, setPostError] = useState(null); async function handlePost() { if (!agent) return; setPosting(true); setPostError(null); try { await agent.com.atproto.repo.createRecord({ collection: "app.bsky.feed.post", repo: agent.assertDid, record: { $type: "app.bsky.feed.post", text: postText, createdAt: new Date().toISOString(), }, }); setPostSuccess(true); setPostText(""); setTimeout(() => { setPostSuccess(false); setPostOpen(false); }, 1500); } catch (e: any) { setPostError(e?.message || "Failed to post"); } finally { setPosting(false); } } return ( <> {postOpen && (

Create Post

{postSuccess ? (
✓ Posted!
) : ( <>