Improved nav

This commit is contained in:
2025-12-10 22:16:26 +01:00
parent e585aa9458
commit 31bd4f32f8
4 changed files with 12 additions and 0 deletions
+1
View File
@@ -37,6 +37,7 @@ export default function Server() {
); );
useEffect(() => { useEffect(() => {
app.setServer(server);
const channelId = searchParams.get("ch"); const channelId = searchParams.get("ch");
if (channelId) { if (channelId) {
app.setCurrentChannel( app.setCurrentChannel(
+5
View File
@@ -21,6 +21,11 @@ export function ChannelItem({ channel, app }: { channel: Channel; app: App }) {
<Card <Card
className="p-2 flex flex-row px-3 items-center gap-2 cursor-pointer hover:bg-accent" className="p-2 flex flex-row px-3 items-center gap-2 cursor-pointer hover:bg-accent"
onClick={() => { onClick={() => {
window.history.replaceState(
null,
"",
`/server/${app.server?.id}?ch=${channel.id}`
);
app.setCurrentChannel(channel); app.setCurrentChannel(channel);
app.setSidebarOpen(false); app.setSidebarOpen(false);
}} }}
+3
View File
@@ -19,6 +19,7 @@ export default function useApp(): App {
const [dms, setDms] = useState<UserProfile[]>([]); const [dms, setDms] = useState<UserProfile[]>([]);
const [servers, setServers] = useState<StringMap<Server>>({}); const [servers, setServers] = useState<StringMap<Server>>({});
const [currentChannel, setCurrentChannel] = useState<Channel | null>(null); const [currentChannel, setCurrentChannel] = useState<Channel | null>(null);
const [server, setServer] = useState<Server>();
useEffect(() => { useEffect(() => {
const stored = Cookies.get("servers"); const stored = Cookies.get("servers");
@@ -39,6 +40,8 @@ export default function useApp(): App {
return { return {
currentChannel, currentChannel,
setCurrentChannel, setCurrentChannel,
server,
setServer,
servers, servers,
setServers, setServers,
dms, dms,
+3
View File
@@ -10,6 +10,9 @@ export default interface App {
node: RefObject<WebSocket | null>; node: RefObject<WebSocket | null>;
profile: UserProfile | null; profile: UserProfile | null;
server: Server | undefined;
setServer: SetState<Server | undefined>;
clientSettings: ClientSettings; clientSettings: ClientSettings;
setClientSettings: SetState<ClientSettings>; setClientSettings: SetState<ClientSettings>;