"use client"; import ProfilePreview, { ProfileImage } from "@/components/ProfilePicture"; import SettingsDialog from "@/components/settings/SettingsDialog"; import AppLayout from "@/components/app/AppLayout"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import useApp from "@/hooks/use-app"; import { ProfileSettings } from "@/types/settings"; import { Server } from "@/types/types"; import { motion } from "framer-motion"; import { ChevronLeft, ChevronRight, Users, Settings, TrendingUp, NetworkIcon, MessagesSquare, } from "lucide-react"; import Link from "next/link"; import StartNewDM from "./StartNewDM"; import AsyncValue from "@/components/AsyncValue"; import { useRouter } from "next/navigation"; import Cookies from "js-cookie"; import { toast } from "sonner"; export default function ChatHub() { const router = useRouter(); const app = useApp(); const recentPeople = app.dms.slice(0, 3); const activeServers: Server[] = Object.values(app.servers).slice(0, 3); const trendingServers: Server[] = [ { id: "7de3138f-e0b6-4d96-8158-8c7e866ba0ff", name: "ORUS", icon_url: "https://github.com/orus-dev.png", channels: [], }, { id: "cee6b20f-7e6a-4071-8df1-aab37f52bbb9", name: "Saturn Client", icon_url: "https://github.com/saturnclientmc.png", channels: [], }, { id: "osui", name: "OSUI Rust Hub", icon_url: "https://github.com/osui-rs.png", channels: [], }, ]; const recentActivity = app.privateMessages.messages.slice(0, 3); return (
{/* Greeting */}
app.setSidebarOpen(true)}>

Hey {app.profile?.display_name || "there"}!

Here's what's happening in your network today.

{/* Recent DMs + Active Servers */}
{/* Recent DMs */} Recently chatted with {recentPeople.length ? ( recentPeople.map((dm) => ( {dm.display_name || dm.id} )) ) : (

No recent DMs yet.

)}
{/* Active Servers */} Active Servers {activeServers.length ? ( activeServers.map((srv) => ( {srv.name} )) ) : (

No servers joined yet.

)}
{/* Recent Activity Feed */} Recent Activity {recentActivity.length ? ( recentActivity.map((msg) => ( app.getUserById(msg.from)} render={({ value: user }) => (

{user?.display_name || ""}

{msg.contents}

)} /> )) ) : (

No recent messages yet.

)}
{/* Server Discovery */} Trending Servers
{trendingServers.map((srv) => ( { try { Cookies.set( "servers", Object.keys({ ...app.servers, [srv.id]: srv, }).join(",") ); app.setServers((prev) => ({ ...prev, [srv.id]: srv, })); router.push(`/server/${srv.id}`); } catch (e: any) { toast.error(e); } }} >

{srv.name}

))}
{/* Quick Actions */}
); }