From 614f8577b2a176d951a46e4df8edb2a1323fe9b9 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Fri, 17 Oct 2025 22:45:01 +0200 Subject: [PATCH] Chat hub page --- src/app/chat/page.tsx | 141 +++++++++++++++++++-- src/components/Sidebar.tsx | 7 +- src/components/settings/SettingsDialog.tsx | 24 ++-- src/hooks/use-app.ts | 3 + src/types/app.ts | 3 + 5 files changed, 156 insertions(+), 22 deletions(-) diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index dd9e76f..65635e0 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -1,24 +1,147 @@ "use client"; +import ProfilePicture from "@/components/ProfilePicture"; +import SettingsDialog from "@/components/settings/SettingsDialog"; import AppSidebar from "@/components/Sidebar"; +import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Separator } from "@/components/ui/separator"; import { useIsMobile } from "@/hooks/is-mobile"; import useApp from "@/hooks/use-app"; +import { ProfileSettings } from "@/types/settings"; +import { Server } from "@/types/types"; +import { motion } from "framer-motion"; +import { + ChevronLeft, + MessageCircle, + Users, + PlusCircle, + Settings, + ChevronRight, +} from "lucide-react"; +import Link from "next/link"; -export default function Chat() { +export default function ChatHub() { const app = useApp(); const isMobile = useIsMobile(); + const recentDMs = app.dms?.slice(0, 5) || []; + // const activeServers = app.servers?.slice(0, 5) || []; + const activeServers: Server[] = []; + return ( - - - isMobile && app.setSidebarOpen(true)}> - Direct Messages - - - - +
+ + {/* Greeting */} +
isMobile && app.setSidebarOpen(true)}> +

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

+

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

+
+ +
+ {/* Recent DMs */} + + + + + Recent DMs + + + + {recentDMs.length ? ( + recentDMs.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. +

+ )} +
+
+
+ + + + {/* Quick Actions */} +
+

Quick Actions

+
+ + + + + +
+
+
+
); } diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 6bfa638..9a97b19 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -54,7 +54,6 @@ export default function AppSidebar({ const [newServer, setNewServer] = useState({ name: "", ip: "" }); const [query, setQuery] = useState(""); const router = useRouter(); - const [filteredDms, setFilteredDms] = useState([]); const dms = useMemo(() => { return Array.from( @@ -69,7 +68,7 @@ export default function AppSidebar({ useEffect(() => { const load = async () => { const users = await Promise.all(dms.map((id) => app.getUserById(id))); - setFilteredDms( + app.setDms( users.filter( (user) => user !== null && @@ -258,7 +257,7 @@ export default function AppSidebar({ ) : ( <> - {filteredDms.map((user) => ( + {app.dms.map((user) => ( ))} - {filteredDms.length === 0 && query.trim() !== "" ? ( + {app.dms.length === 0 && query.trim() !== "" ? (
+ {children ? ( + children + ) : ( + + )} diff --git a/src/hooks/use-app.ts b/src/hooks/use-app.ts index 59dc115..ec226ec 100644 --- a/src/hooks/use-app.ts +++ b/src/hooks/use-app.ts @@ -13,8 +13,11 @@ export default function useApp(): App { const [sidebarOpen, setSidebarOpen] = useState(false); const profile = useUser(); const [clientSettings, setClientSettings] = useClientSettings(); + const [dms, setDms] = useState([]); return { + dms, + setDms, node, clientSettings, setClientSettings, diff --git a/src/types/app.ts b/src/types/app.ts index 834fff5..2624abb 100644 --- a/src/types/app.ts +++ b/src/types/app.ts @@ -23,4 +23,7 @@ export default interface App { setSidebarOpen: SetState; getUserById: (userId: string) => Promise; + + dms: UserProfile[]; + setDms: SetState; }