diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index 4996c92..b9ab8d1 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -12,30 +12,56 @@ import { Server } from "@/types/types"; import { motion } from "framer-motion"; import { ChevronLeft, - MessageCircle, - Users, - PlusCircle, - Settings, 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 app = useApp(); + const router = useRouter(); - const recentDMs = app.dms?.slice(0, 5) || []; - // const activeServers = app.servers?.slice(0, 5) || []; - const activeServers: Server[] = []; + const app = useApp(); + const recentPeople = app.dms.slice(0, 3); + const activeServers: Server[] = Object.values(app.servers).slice(0, 3); + const trendingServers: Server[] = [ + { + id: "cee6b20f-7e6a-4071-8df1-aab37f52bbb9", + 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: "cee6b20f-7e6a-4071-8df1-aab37f52bbb9", + name: "OSUI Rust Hub", + icon_url: "https://github.com/osui-rs.png", + channels: [], + }, + ]; + const recentActivity = app.messages.slice(0, 3); return ( -
+
{/* Greeting */}
app.setSidebarOpen(true)}> @@ -48,22 +74,23 @@ export default function ChatHub() {

+ {/* Recent DMs + Active Servers */}
{/* Recent DMs */} - - Recent DMs + + Recently chatted with - {recentDMs.length ? ( - recentDMs.map((dm) => ( + {recentPeople.length ? ( + recentPeople.map((dm) => ( - + Active Servers @@ -99,10 +126,13 @@ export default function ChatHub() { - + {srv.name} @@ -117,11 +147,106 @@ export default function ChatHub() {
+ {/* 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 */} -
- {/*

Quick Actions

*/} +
{Object.values(app.servers).map( - (srv) => + (srv, i) => srv && ( - + )