import React, { useState } from "react"; import { QueryClientProvider, QueryClient } from "@tanstack/react-query"; import { AuthCtx } from "./context"; import { useIsDesktop } from "./hooks"; import { ComposeTweet } from "./components/compose"; import { Feed, FollowingFeed, RefreshButton } from "./components/feed"; import { TweetDetail } from "./components/tweet-detail"; import { UserList, UserDetail } from "./components/users"; import { MyProfile } from "./components/profile"; import { MobileNav, MobileComposePage } from "./components/nav"; const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 10_000 } }, }); export function App() { const appEl = document.getElementById("app")!; const email = appEl.dataset.currentUserEmail ?? ""; const userId = appEl.dataset.currentUserId ?? ""; const username = appEl.dataset.currentUserUsername ?? ""; const displayName = appEl.dataset.currentUserDisplayName ?? ""; const avatarUrl = appEl.dataset.currentUserAvatarUrl ?? ""; const tweetId = appEl.dataset.tweetId || null; const page = appEl.dataset.page ?? "feed"; const profileUserId = appEl.dataset.userId || null; const [mobileCompose, setMobileCompose] = useState(false); const isDesktop = useIsDesktop(); const onFeedPage = page === "feed" || page === "tweet"; const onFollowingPage = page === "following"; const onUsersPage = page === "users" || page === "user-detail"; const onProfilePage = page === "profile"; function renderMain() { switch (page) { case "tweet": return ( <>

Tweet

); case "following": return ( <>

Following

); case "users": return ( <>

Users

); case "user-detail": return ( <>

Profile

); case "profile": return ( <>

My Profile

); default: return ( <>

Feed

{email ? ( ) : (

Sign in to start mixing.

Sign in
)}
); } } return (
{isDesktop && ( )}
{renderMain()}
{isDesktop && (

About Mixer

A minimal social feed built with Ash Framework, Phoenix, and React.

{["Ash 3", "Phoenix 1.8", "AshTypescript", "React 19"].map((s) => ( {s} ))}
)}
setMobileCompose(true)} /> {mobileCompose && ( setMobileCompose(false)} /> )}
); }