From 614f8577b2a176d951a46e4df8edb2a1323fe9b9 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Fri, 17 Oct 2025 22:45:01 +0200 Subject: [PATCH 1/2] 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; } From 8ece6eca10f866a08fd6cbbc645fbac760134d50 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Fri, 17 Oct 2025 22:52:25 +0200 Subject: [PATCH 2/2] Sidebar fix --- src/app/chat/page.tsx | 6 ++---- src/components/MessageBox.tsx | 7 ++----- src/components/Sidebar.tsx | 6 ++++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index 65635e0..a35b042 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -6,7 +6,6 @@ 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"; @@ -23,7 +22,6 @@ import Link from "next/link"; export default function ChatHub() { const app = useApp(); - const isMobile = useIsMobile(); const recentDMs = app.dms?.slice(0, 5) || []; // const activeServers = app.servers?.slice(0, 5) || []; @@ -31,7 +29,7 @@ export default function ChatHub() { return ( -
+
{/* Greeting */} -
isMobile && app.setSidebarOpen(true)}> +
app.setSidebarOpen(true)}>

Hey {app.profile?.display_name || "there"} diff --git a/src/components/MessageBox.tsx b/src/components/MessageBox.tsx index 18c0019..50d3bb6 100644 --- a/src/components/MessageBox.tsx +++ b/src/components/MessageBox.tsx @@ -11,15 +11,13 @@ import { DropdownMenuTrigger, } from "./ui/dropdown-menu"; import { ChevronLeftIcon, SendIcon, SmilePlusIcon } from "lucide-react"; -import { useEffect, useRef, useState } from "react"; +import { useRef, useState } from "react"; import { format, isToday, isYesterday } from "date-fns"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; import { UserProfile } from "@/hooks/get-user"; -import axios from "axios"; import ProfilePicture from "./ProfilePicture"; import App from "@/types/app"; -import { useIsMobile } from "@/hooks/use-mobile"; import { Textarea } from "./ui/textarea"; function MessageContainer({ message, app }: { message: Message; app: App }) { @@ -130,7 +128,6 @@ export default function MessageBox({ messages: Message[]; }) { const [text, setText] = useState(""); - const isMobile = useIsMobile(); const inputRef = useRef(null); return ( @@ -138,7 +135,7 @@ export default function MessageBox({ {channelName && (
isMobile && app.setSidebarOpen(true)} + onClick={() => app.setSidebarOpen(true)} className="cursor-pointer flex" > diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 9a97b19..1b887b7 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -36,6 +36,7 @@ import { cn } from "@/lib/utils"; import App from "@/types/app"; import { ProfileSettings } from "@/types/settings"; import axios from "axios"; +import { useIsMobile } from "@/hooks/is-mobile"; export default function AppSidebar({ children, @@ -54,6 +55,7 @@ export default function AppSidebar({ const [newServer, setNewServer] = useState({ name: "", ip: "" }); const [query, setQuery] = useState(""); const router = useRouter(); + const isMobile = useIsMobile(); const dms = useMemo(() => { return Array.from( @@ -138,7 +140,7 @@ export default function AppSidebar({
@@ -302,7 +304,7 @@ export default function AppSidebar({
- {app.sidebarOpen ? ( + {app.sidebarOpen && isMobile ? (
app.setSidebarOpen(false)}