From 1581938c64e86c52b427912f81081abeb0b6c3a8 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sun, 26 Oct 2025 20:22:25 +0100 Subject: [PATCH 1/4] Better hub --- src/app/chat/page.tsx | 120 ++++++++++++++++++++++++++++++---- src/components/AsyncValue.tsx | 19 ++++++ 2 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 src/components/AsyncValue.tsx diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index 4996c92..3cbcd61 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -12,30 +12,42 @@ import { Server } from "@/types/types"; import { motion } from "framer-motion"; import { ChevronLeft, + ChevronRight, MessageCircle, Users, - PlusCircle, Settings, - ChevronRight, + PlusCircle, } from "lucide-react"; import Link from "next/link"; import StartNewDM from "./StartNewDM"; +import AsyncValue from "@/components/AsyncValue"; export default function ChatHub() { const app = useApp(); const recentDMs = app.dms?.slice(0, 5) || []; - // const activeServers = app.servers?.slice(0, 5) || []; - const activeServers: Server[] = []; + const activeServers: Server[] = Object.values(app.servers).slice(0, 5) || []; + const suggestedServers: Server[] = [ + { id: "1", name: "Frontend Devs", icon_url: "", channels: [] }, + { id: "2", name: "Gamers Lounge", icon_url: "", channels: [] }, + { id: "3", name: "Music Hub", icon_url: "", channels: [] }, + ]; + const recentActivity = app.messages.slice(0, 5); + + const stats = { + dms: app.dms?.length || 0, + servers: app.servers?.length || 0, + // friends: app.friends?.length || 0, + }; return ( -
+
{/* Greeting */}
app.setSidebarOpen(true)}> @@ -44,10 +56,11 @@ export default function ChatHub() { Hey {app.profile?.display_name || "there"}!

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

+ {/* Recent DMs + Active Servers */}
{/* Recent DMs */} @@ -63,7 +76,7 @@ export default function ChatHub() { - + {srv.name} @@ -117,11 +133,89 @@ 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 */} + + + + + Discover Servers + + + +
+ {suggestedServers.map((srv) => ( + + + + +

{srv.name}

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

Quick Actions

*/} +
{Object.values(app.servers).map( - (srv) => + (srv, i) => srv && ( - + ) From 903d0d2fa6272e6642d174834b8fa885c7bb59aa Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sun, 26 Oct 2025 21:06:02 +0100 Subject: [PATCH 3/4] Finer chat hub --- src/app/chat/page.tsx | 93 ++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index 3cbcd61..b9ab8d1 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -13,32 +13,46 @@ import { motion } from "framer-motion"; import { ChevronLeft, ChevronRight, - MessageCircle, Users, Settings, - PlusCircle, + 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 recentDMs = app.dms?.slice(0, 5) || []; - const activeServers: Server[] = Object.values(app.servers).slice(0, 5) || []; - const suggestedServers: Server[] = [ - { id: "1", name: "Frontend Devs", icon_url: "", channels: [] }, - { id: "2", name: "Gamers Lounge", icon_url: "", channels: [] }, - { id: "3", name: "Music Hub", icon_url: "", channels: [] }, + 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, 5); - - const stats = { - dms: app.dms?.length || 0, - servers: app.servers?.length || 0, - // friends: app.friends?.length || 0, - }; + const recentActivity = app.messages.slice(0, 3); return ( @@ -56,7 +70,7 @@ export default function ChatHub() { Hey {app.profile?.display_name || "there"}!

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

@@ -66,13 +80,13 @@ export default function ChatHub() { - - Recent DMs + + Recently chatted with - {recentDMs.length ? ( - recentDMs.map((dm) => ( + {recentPeople.length ? ( + recentPeople.map((dm) => ( - + Active Servers @@ -137,7 +151,7 @@ export default function ChatHub() { - + Recent Activity @@ -184,26 +198,43 @@ export default function ChatHub() { - - Discover Servers + + Trending Servers
- {suggestedServers.map((srv) => ( + {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}

-
From 990653cb2fbae2c53d2c5e7a610befcdb531c081 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sun, 26 Oct 2025 21:11:12 +0100 Subject: [PATCH 4/4] Fixed sidebar DMs dupes? --- src/components/app/SidebarDMs.tsx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/app/SidebarDMs.tsx b/src/components/app/SidebarDMs.tsx index c1be647..148fe8e 100644 --- a/src/components/app/SidebarDMs.tsx +++ b/src/components/app/SidebarDMs.tsx @@ -20,17 +20,18 @@ export default function SidebarDMs({ app }: { app: App }) { if (!app.profile) return; const load = async () => { - const users = [ - ...new Set( - await Promise.all( - app.messages - .sort((a, b) => a.timestamp - b.timestamp) - .flatMap((m) => [m.from, m.channel_id]) - .filter((id) => id !== app.profile?.id) - .map((id) => app.getUserById(id)) - ) - ), - ].filter((v) => !!v); + const users = ( + await Promise.all( + [ + ...new Set( + app.messages + .sort((a, b) => a.timestamp - b.timestamp) + .flatMap((m) => [m.from, m.channel_id]) + .filter((id) => id !== app.profile?.id) + ), + ].map((id) => app.getUserById(id)) + ) + ).filter((v) => !!v); app.setDms(users);