fix: register forum/thread routes at top level + notification dots in ServerBar

Moved thread and forum-tag routes from nested /servers/{sid}/channels/ to
top-level /channels/{id}/... to match frontend API calls. Forum posts were
getting SPA HTML fallback instead of JSON.

Added orange notification dots to DM and server buttons in ServerBar.
This commit is contained in:
2026-07-10 09:45:37 -04:00
parent 87d7345155
commit 56af584ede
3 changed files with 60 additions and 27 deletions
+13
View File
@@ -250,6 +250,19 @@ func main() {
r.Post("/", calHandler.CreateEvent) r.Post("/", calHandler.CreateEvent)
}) })
// Threads (forum posts)
threadHandler := channel.NewHandler(database.DB, permissionsChecker)
r.Route("/channels/{channelID}/threads", func(r chi.Router) {
r.Get("/", threadHandler.ListThreads)
r.Post("/", threadHandler.CreateThread)
})
r.Patch("/threads/{threadID}", threadHandler.UpdateThread)
// Forum tags
r.Get("/channels/{channelID}/forum-tags", threadHandler.ListForumTags)
r.Post("/channels/{channelID}/forum-tags", threadHandler.CreateForumTag)
r.Delete("/forum-tags/{tagID}", threadHandler.DeleteForumTag)
// Push notifications // Push notifications
pushHandler.RegisterRoutes(r) pushHandler.RegisterRoutes(r)
+1 -4
View File
@@ -27,10 +27,7 @@ func (h *Handler) RegisterRoutes(r chi.Router) {
r.Get("/{channelID}", h.Get) r.Get("/{channelID}", h.Get)
r.Patch("/{channelID}", h.Update) r.Patch("/{channelID}", h.Update)
r.Delete("/{channelID}", h.Delete) r.Delete("/{channelID}", h.Delete)
r.Post("/{channelID}/threads", h.CreateThread) // ponytail: thread + forum routes registered at top level in main.go to match frontend paths
r.Get("/{channelID}/threads", h.ListThreads)
r.Patch("/threads/{threadID}", h.UpdateThread)
h.registerForumRoutes(r)
h.RegisterCalendarRoutes(r) h.RegisterCalendarRoutes(r)
h.registerDocRoutes(r) h.registerDocRoutes(r)
h.registerListRoutes(r) h.registerListRoutes(r)
+46 -23
View File
@@ -1,8 +1,10 @@
import { useEffect, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useServerStore } from "../stores/server.ts"; import { useServerStore } from "../stores/server.ts";
import { useChannelStore } from "../stores/channel.ts"; import { useChannelStore } from "../stores/channel.ts";
import { useLayoutStore } from "../stores/layout.ts"; import { useLayoutStore } from "../stores/layout.ts";
import { useConversationStore } from "../stores/conversation.ts";
import { useReadStatesStore } from "../stores/readStates.ts";
import { CreateServerModal } from "./CreateServerModal.tsx"; import { CreateServerModal } from "./CreateServerModal.tsx";
import { JoinServerModal } from "./JoinServerModal.tsx"; import { JoinServerModal } from "./JoinServerModal.tsx";
import { ServerSettingsModal } from "./ServerSettingsModal.tsx"; import { ServerSettingsModal } from "./ServerSettingsModal.tsx";
@@ -33,6 +35,18 @@ export function ServerBar() {
const { showMenu, MenuPortal } = useContextMenu(); const { showMenu, MenuPortal } = useContextMenu();
// ponytail: compute if any DM conversation has unread messages
const conversations = useConversationStore((s) => s.conversations);
const messagesByConv = useConversationStore((s) => s.messagesByConversation);
const hasConvUnread = useReadStatesStore((s) => s.hasConvUnread);
const hasAnyDMUnread = useMemo(() => {
return conversations.some((conv) => {
const msgs = messagesByConv[conv.id] || [];
const latestId = msgs.length > 0 ? msgs[msgs.length - 1].id : undefined;
return hasConvUnread(conv.id, latestId);
});
}, [conversations, messagesByConv, hasConvUnread]);
useEffect(() => { useEffect(() => {
fetchServers().then(() => { fetchServers().then(() => {
// ponytail: restore last active server + channel from localStorage // ponytail: restore last active server + channel from localStorage
@@ -94,34 +108,43 @@ export function ServerBar() {
return ( return (
<> <>
<div className="h-full w-16 bg-gb-bg-h border-r border-gb-bg-t flex flex-col items-center py-3 gap-2 overflow-y-auto"> <div className="h-full w-16 bg-gb-bg-h border-r border-gb-bg-t flex flex-col items-center py-3 gap-2 overflow-y-auto">
<button <div className="relative">
onClick={handleDM}
className={'w-11 h-11 flex items-center justify-center font-mono text-sm border ' +
(isDM
? 'bg-gb-bg-t text-gb-orange border-gb-orange'
: 'bg-gb-bg-s text-gb-fg border-gb-bg-t hover:border-gb-fg-t hover:text-gb-aqua')}
title="Direct messages"
>
[@]
</button>
<div className="w-8 h-px bg-gb-bg-t" />
{servers.map((server) => (
<button <button
key={server.id} onClick={handleDM}
onClick={() => handleSelect(server.id)}
onContextMenu={(e) => handleServerContextMenu(e, server)}
className={'w-11 h-11 flex items-center justify-center font-mono text-sm border ' + className={'w-11 h-11 flex items-center justify-center font-mono text-sm border ' +
(server.id === activeServerId && !isDM (isDM
? 'bg-gb-bg-t text-gb-orange border-gb-orange' ? 'bg-gb-bg-t text-gb-orange border-gb-orange'
: 'bg-gb-bg-s text-gb-fg border-gb-bg-t hover:border-gb-fg-t hover:text-gb-aqua')} : 'bg-gb-bg-s text-gb-fg border-gb-bg-t hover:border-gb-fg-t hover:text-gb-aqua')}
title={server.name} title="Direct messages"
> >
{server.unread && server.id !== activeServerId ? ( [@]
<span className="text-gb-aqua">[{getInitials(server.name)}]</span>
) : (
'[' + getInitials(server.name) + ']'
)}
</button> </button>
{hasAnyDMUnread && !isDM && (
<span className="absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 bg-gb-orange rounded-full border-2 border-gb-bg-h" />
)}
</div>
<div className="w-8 h-px bg-gb-bg-t" />
{servers.map((server) => (
<div key={server.id} className="relative">
<button
onClick={() => handleSelect(server.id)}
onContextMenu={(e) => handleServerContextMenu(e, server)}
className={'w-11 h-11 flex items-center justify-center font-mono text-sm border ' +
(server.id === activeServerId && !isDM
? 'bg-gb-bg-t text-gb-orange border-gb-orange'
: 'bg-gb-bg-s text-gb-fg border-gb-bg-t hover:border-gb-fg-t hover:text-gb-aqua')}
title={server.name}
>
{server.unread && server.id !== activeServerId ? (
<span className="text-gb-aqua">[{getInitials(server.name)}]</span>
) : (
'[' + getInitials(server.name) + ']'
)}
</button>
{server.unread && server.id !== activeServerId && (
<span className="absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 bg-gb-orange rounded-full border-2 border-gb-bg-h" />
)}
</div>
))} ))}
<div className="mt-2 flex flex-col gap-2 items-center"> <div className="mt-2 flex flex-col gap-2 items-center">
<button <button