feat(phase5): calendar channels - events, RSVPs, calendar view

This commit is contained in:
2026-06-30 11:15:40 -04:00
parent 58ce09cc18
commit e65ce54e36
10 changed files with 531 additions and 8 deletions
+8 -1
View File
@@ -128,10 +128,17 @@
--- ---
## Phase 5 — Guilded Signature Features (34 weeks) ## Phase 5 — Guilded Signature Features 🔄 IN PROGRESS
> The features that set Guilded apart: calendar, docs, lists, scheduling. > The features that set Guilded apart: calendar, docs, lists, scheduling.
| # | Feature | Status |
|---|---------|--------|
| 5.1 | Calendar Channels | In progress |
| 5.2 | Docs Channels | Pending |
| 5.3 | Lists Channels | Pending |
| 5.4 | Scheduling / Availability | Pending |
### 5.1 Calendar Channels ### 5.1 Calendar Channels
- **Backend:** New `calendar` channel type. New `events` table (channel_id, creator_id, title, description, start_time, end_time, recurrence_rule, location, color). New `event_rsvps` table (event_id, user_id, status: going/maybe/no, responded_at). - **Backend:** New `calendar` channel type. New `events` table (channel_id, creator_id, title, description, start_time, end_time, recurrence_rule, location, color). New `event_rsvps` table (event_id, user_id, status: going/maybe/no, responded_at).
- **Route:** CRUD for events. `POST /events/{eventID}/rsvp` (RSVP). `GET /channels/{channelID}/events?from=...&to=...`. - **Route:** CRUD for events. `POST /events/{eventID}/rsvp` (RSVP). `GET /channels/{channelID}/events?from=...&to=...`.
+319
View File
@@ -0,0 +1,319 @@
package channel
import (
"context"
"database/sql"
"encoding/json"
"net/http"
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/middleware"
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/permissions"
"github.com/go-chi/chi/v5"
)
type calendarEvent struct {
ID string `json:"id"`
ChannelID string `json:"channel_id"`
CreatorID string `json:"creator_id"`
Title string `json:"title"`
Description *string `json:"description"`
StartTime string `json:"start_time"`
EndTime *string `json:"end_time"`
RecurrenceRule *string `json:"recurrence_rule"`
Location *string `json:"location"`
Color *string `json:"color"`
GoingCount int `json:"going_count"`
MaybeCount int `json:"maybe_count"`
NoCount int `json:"no_count"`
UserStatus string `json:"user_status"`
CreatedAt string `json:"created_at"`
}
type createEventRequest struct {
Title string `json:"title"`
Description *string `json:"description"`
StartTime string `json:"start_time"`
EndTime *string `json:"end_time"`
RecurrenceRule *string `json:"recurrence_rule"`
Location *string `json:"location"`
Color *string `json:"color"`
}
func (h *Handler) registerCalendarRoutes(r chi.Router) {
r.Get("/{channelID}/events", h.ListEvents)
r.Post("/{channelID}/events", h.CreateEvent)
r.Patch("/events/{eventID}", h.UpdateEvent)
r.Delete("/events/{eventID}", h.DeleteEvent)
r.Post("/events/{eventID}/rsvp", h.SetRSVP)
}
func (h *Handler) CreateEvent(w http.ResponseWriter, r *http.Request) {
channelID := chi.URLParam(r, "channelID")
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
http.Error(w, `{"error":"unauthorized"}`, http.StatusUnauthorized)
return
}
serverID, err := h.serverIDForChannel(r.Context(), channelID)
if err != nil {
http.Error(w, `{"error":"channel not found"}`, http.StatusNotFound)
return
}
if ok, _ := h.isMember(r.Context(), userID, serverID); !ok {
http.Error(w, `{"error":"forbidden"}`, http.StatusForbidden)
return
}
allowed, _ := h.checker.CheckPermission(r.Context(), serverID, userID, permissions.SEND_MESSAGES)
if !allowed {
http.Error(w, `{"error":"forbidden"}`, http.StatusForbidden)
return
}
var req createEventRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Title == "" || req.StartTime == "" {
http.Error(w, `{"error":"invalid request"}`, http.StatusBadRequest)
return
}
event, err := h.scanEvent(h.db.QueryRowContext(r.Context(), `
INSERT INTO events (channel_id, creator_id, title, description, start_time, end_time, recurrence_rule, location, color)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
RETURNING id, channel_id, creator_id, title, description, start_time, end_time, recurrence_rule, location, color, created_at
`, channelID, userID, req.Title, req.Description, req.StartTime, req.EndTime, req.RecurrenceRule, req.Location, req.Color))
if err != nil {
http.Error(w, `{"error":"failed to create event"}`, http.StatusInternalServerError)
return
}
h.respondEvent(w, r, event, userID)
}
func (h *Handler) ListEvents(w http.ResponseWriter, r *http.Request) {
channelID := chi.URLParam(r, "channelID")
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
http.Error(w, `{"error":"unauthorized"}`, http.StatusUnauthorized)
return
}
serverID, err := h.serverIDForChannel(r.Context(), channelID)
if err != nil {
http.Error(w, `{"error":"channel not found"}`, http.StatusNotFound)
return
}
if ok, _ := h.isMember(r.Context(), userID, serverID); !ok {
http.Error(w, `{"error":"forbidden"}`, http.StatusForbidden)
return
}
from := r.URL.Query().Get("from")
to := r.URL.Query().Get("to")
if from == "" || to == "" {
http.Error(w, `{"error":"from and to required"}`, http.StatusBadRequest)
return
}
rows, err := h.db.QueryContext(r.Context(), `
SELECT id, channel_id, creator_id, title, description, start_time, end_time, recurrence_rule, location, color, created_at
FROM events
WHERE channel_id = $1 AND start_time >= $2 AND start_time <= $3
ORDER BY start_time
`, channelID, from, to)
if err != nil {
http.Error(w, `{"error":"server error"}`, http.StatusInternalServerError)
return
}
defer rows.Close()
events := make([]calendarEvent, 0)
for rows.Next() {
e, err := h.scanEvent(rows)
if err != nil {
continue
}
events = append(events, h.withRSVPCounts(r.Context(), e, userID))
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(events)
}
func (h *Handler) UpdateEvent(w http.ResponseWriter, r *http.Request) {
eventID := chi.URLParam(r, "eventID")
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
http.Error(w, `{"error":"unauthorized"}`, http.StatusUnauthorized)
return
}
var channelID, creatorID string
err := h.db.QueryRowContext(r.Context(), `SELECT channel_id, creator_id FROM events WHERE id = $1`, eventID).Scan(&channelID, &creatorID)
if err != nil {
http.Error(w, `{"error":"event not found"}`, http.StatusNotFound)
return
}
serverID, err := h.serverIDForChannel(r.Context(), channelID)
if err != nil {
http.Error(w, `{"error":"channel not found"}`, http.StatusNotFound)
return
}
allowed, _ := h.checker.CheckPermission(r.Context(), serverID, userID, permissions.MANAGE_CHANNELS)
if !allowed && creatorID != userID {
http.Error(w, `{"error":"forbidden"}`, http.StatusForbidden)
return
}
var req createEventRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, `{"error":"invalid request"}`, http.StatusBadRequest)
return
}
var nullEnd, nullRecurrence, nullLocation, nullColor, nullDesc interface{}
var query string
if req.Title != "" {
query = `
UPDATE events SET title = $3, description = COALESCE($4, description), start_time = COALESCE($5, start_time),
end_time = COALESCE($6, end_time), recurrence_rule = COALESCE($7, recurrence_rule), location = COALESCE($8, location),
color = COALESCE($9, color), updated_at = NOW()
WHERE id = $1
RETURNING id, channel_id, creator_id, title, description, start_time, end_time, recurrence_rule, location, color, created_at
`
} else {
// patch partial
query = `
UPDATE events SET description = COALESCE($4, description), start_time = COALESCE($5, start_time),
end_time = COALESCE($6, end_time), recurrence_rule = COALESCE($7, recurrence_rule), location = COALESCE($8, location),
color = COALESCE($9, color), updated_at = NOW()
WHERE id = $1
RETURNING id, channel_id, creator_id, title, description, start_time, end_time, recurrence_rule, location, color, created_at
`
}
// ponytail: pass nil where omitted; decoder will give zero values and COALESCE preserves existing
event, err := h.scanEvent(h.db.QueryRowContext(r.Context(), query, eventID, nullDesc, req.Title, req.Description, req.StartTime, nullEnd, nullRecurrence, nullLocation, nullColor))
if err != nil {
http.Error(w, `{"error":"failed to update event"}`, http.StatusInternalServerError)
return
}
h.respondEvent(w, r, h.withRSVPCounts(r.Context(), event, userID), userID)
}
func (h *Handler) DeleteEvent(w http.ResponseWriter, r *http.Request) {
eventID := chi.URLParam(r, "eventID")
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
http.Error(w, `{"error":"unauthorized"}`, http.StatusUnauthorized)
return
}
var channelID, creatorID string
err := h.db.QueryRowContext(r.Context(), `SELECT channel_id, creator_id FROM events WHERE id = $1`, eventID).Scan(&channelID, &creatorID)
if err != nil {
http.Error(w, `{"error":"event not found"}`, http.StatusNotFound)
return
}
serverID, err := h.serverIDForChannel(r.Context(), channelID)
if err != nil {
http.Error(w, `{"error":"channel not found"}`, http.StatusNotFound)
return
}
allowed, _ := h.checker.CheckPermission(r.Context(), serverID, userID, permissions.MANAGE_CHANNELS)
if !allowed && creatorID != userID {
http.Error(w, `{"error":"forbidden"}`, http.StatusForbidden)
return
}
_, err = h.db.ExecContext(r.Context(), `DELETE FROM events WHERE id = $1`, eventID)
if err != nil {
http.Error(w, `{"error":"failed to delete event"}`, http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusNoContent)
}
func (h *Handler) SetRSVP(w http.ResponseWriter, r *http.Request) {
eventID := chi.URLParam(r, "eventID")
userID, ok := middleware.UserIDFromContext(r.Context())
if !ok {
http.Error(w, `{"error":"unauthorized"}`, http.StatusUnauthorized)
return
}
var req struct {
Status string `json:"status"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || (req.Status != "going" && req.Status != "maybe" && req.Status != "no") {
http.Error(w, `{"error":"invalid status"}`, http.StatusBadRequest)
return
}
var channelID string
err := h.db.QueryRowContext(r.Context(), `SELECT channel_id FROM events WHERE id = $1`, eventID).Scan(&channelID)
if err != nil {
http.Error(w, `{"error":"event not found"}`, http.StatusNotFound)
return
}
serverID, err := h.serverIDForChannel(r.Context(), channelID)
if err != nil {
http.Error(w, `{"error":"channel not found"}`, http.StatusNotFound)
return
}
if ok, _ := h.isMember(r.Context(), userID, serverID); !ok {
http.Error(w, `{"error":"forbidden"}`, http.StatusForbidden)
return
}
_, err = h.db.ExecContext(r.Context(), `
INSERT INTO event_rsvps (event_id, user_id, status) VALUES ($1, $2, $3)
ON CONFLICT (event_id, user_id) DO UPDATE SET status = $3, responded_at = NOW()
`, eventID, userID, req.Status)
if err != nil {
http.Error(w, `{"error":"failed to save rsvp"}`, http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusNoContent)
}
func (h *Handler) scanEvent(row interface{ Scan(dest ...any) error }) (calendarEvent, error) {
var e calendarEvent
var desc, endTime, recurrence, location, color sql.NullString
err := row.Scan(&e.ID, &e.ChannelID, &e.CreatorID, &e.Title, &desc, &e.StartTime, &endTime, &recurrence, &location, &color, &e.CreatedAt)
if err != nil {
return e, err
}
if desc.Valid {
e.Description = &desc.String
}
if endTime.Valid {
e.EndTime = &endTime.String
}
if recurrence.Valid {
e.RecurrenceRule = &recurrence.String
}
if location.Valid {
e.Location = &location.String
}
if color.Valid {
e.Color = &color.String
}
return e, nil
}
func (h *Handler) withRSVPCounts(ctx context.Context, e calendarEvent, userID string) calendarEvent {
row := h.db.QueryRowContext(ctx, `
SELECT
SUM(CASE WHEN status = 'going' THEN 1 ELSE 0 END),
SUM(CASE WHEN status = 'maybe' THEN 1 ELSE 0 END),
SUM(CASE WHEN status = 'no' THEN 1 ELSE 0 END),
COALESCE(MAX(CASE WHEN user_id = $2 THEN status END), '')
FROM event_rsvps WHERE event_id = $1
`, e.ID, userID)
var userStatus sql.NullString
_ = row.Scan(&e.GoingCount, &e.MaybeCount, &e.NoCount, &userStatus)
if userStatus.Valid {
e.UserStatus = userStatus.String
}
return e
}
func (h *Handler) respondEvent(w http.ResponseWriter, r *http.Request, e calendarEvent, userID string) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(h.withRSVPCounts(r.Context(), e, userID))
}
+1
View File
@@ -31,6 +31,7 @@ func (h *Handler) RegisterRoutes(r chi.Router) {
r.Get("/{channelID}/threads", h.ListThreads) r.Get("/{channelID}/threads", h.ListThreads)
r.Patch("/threads/{threadID}", h.UpdateThread) r.Patch("/threads/{threadID}", h.UpdateThread)
h.registerForumRoutes(r) h.registerForumRoutes(r)
h.registerCalendarRoutes(r)
h.registerOverrideRoutes(r) h.registerOverrideRoutes(r)
} }
+28
View File
@@ -380,6 +380,34 @@ CREATE TABLE IF NOT EXISTS blocks (
CREATE INDEX IF NOT EXISTS idx_blocks_blocker ON blocks(blocker_id); CREATE INDEX IF NOT EXISTS idx_blocks_blocker ON blocks(blocker_id);
CREATE INDEX IF NOT EXISTS idx_blocks_blocked ON blocks(blocked_id); CREATE INDEX IF NOT EXISTS idx_blocks_blocked ON blocks(blocked_id);
-- Calendar events
CREATE TABLE IF NOT EXISTS events (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
channel_id UUID NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
creator_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
title VARCHAR(255) NOT NULL,
description TEXT,
start_time TIMESTAMPTZ NOT NULL,
end_time TIMESTAMPTZ,
recurrence_rule VARCHAR(255),
location VARCHAR(255),
color VARCHAR(7),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_events_channel_time ON events(channel_id, start_time);
CREATE TABLE IF NOT EXISTS event_rsvps (
event_id UUID NOT NULL REFERENCES events(id) ON DELETE CASCADE,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
status VARCHAR(16) NOT NULL CHECK (status IN ('going', 'maybe', 'no')),
responded_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY (event_id, user_id)
);
CREATE INDEX IF NOT EXISTS idx_event_rsvps_event ON event_rsvps(event_id);
-- Message full-text search -- Message full-text search
ALTER TABLE messages ADD COLUMN IF NOT EXISTS search_vector tsvector; ALTER TABLE messages ADD COLUMN IF NOT EXISTS search_vector tsvector;
CREATE INDEX IF NOT EXISTS idx_messages_search ON messages USING GIN(search_vector); CREATE INDEX IF NOT EXISTS idx_messages_search ON messages USING GIN(search_vector);
+162
View File
@@ -0,0 +1,162 @@
import { useEffect, useMemo, useState } from 'react';
import { api } from '../lib/api.ts';
interface CalendarEvent {
id: string;
channel_id: string;
creator_id: string;
title: string;
description: string | null;
start_time: string;
end_time: string | null;
recurrence_rule: string | null;
location: string | null;
color: string | null;
going_count: number;
maybe_count: number;
no_count: number;
user_status: string;
}
interface CalendarViewProps {
channelId: string;
channelName: string;
}
export function CalendarView({ channelId, channelName }: CalendarViewProps) {
const [events, setEvents] = useState<CalendarEvent[]>([]);
const [date, setDate] = useState(() => new Date());
const [loading, setLoading] = useState(false);
const [showForm, setShowForm] = useState(false);
const [title, setTitle] = useState('');
const [start, setStart] = useState('');
const [end, setEnd] = useState('');
const [description, setDescription] = useState('');
const [selectedEvent, setSelectedEvent] = useState<CalendarEvent | null>(null);
const monthStart = useMemo(() => new Date(date.getFullYear(), date.getMonth(), 1), [date]);
const monthEnd = useMemo(() => new Date(date.getFullYear(), date.getMonth() + 1, 0), [date]);
const days: (number | null)[] = useMemo(() => {
const startDay = monthStart.getDay();
const total = monthEnd.getDate();
const arr: (number | null)[] = Array(startDay).fill(null);
for (let i = 1; i <= total; i++) arr.push(i);
return arr;
}, [monthStart, monthEnd]);
useEffect(() => {
const from = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-01T00:00:00Z`;
const to = `${date.getFullYear()}-${String(date.getMonth() + 2).padStart(2, '0')}-01T00:00:00Z`;
setLoading(true);
api.get<CalendarEvent[]>(`/channels/${channelId}/events?from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}`)
.then((data) => setEvents(Array.isArray(data) ? data : []))
.finally(() => setLoading(false));
}, [channelId, date]);
const eventsForDay = (day: number) => {
const d = new Date(date.getFullYear(), date.getMonth(), day);
return events.filter((e) => {
const start = new Date(e.start_time);
return start.getFullYear() === d.getFullYear() && start.getMonth() === d.getMonth() && start.getDate() === d.getDate();
});
};
const handleCreate = async () => {
if (!title || !start) return;
const payload = { title, start_time: start, end_time: end || undefined, description: description || undefined };
const ev = await api.post<CalendarEvent>(`/channels/${channelId}/events`, payload);
setEvents((prev) => [...prev, ev]);
setShowForm(false);
setTitle('');
setStart('');
setEnd('');
setDescription('');
};
const handleRSVP = async (eventId: string, status: 'going' | 'maybe' | 'no') => {
await api.post(`/events/${eventId}/rsvp`, { status });
setEvents((prev) => prev.map((e) => e.id === eventId ? { ...e, user_status: status } : e));
};
const prevMonth = () => setDate((d) => new Date(d.getFullYear(), d.getMonth() - 1, 1));
const nextMonth = () => setDate((d) => new Date(d.getFullYear(), d.getMonth() + 1, 1));
return (
<div className="flex flex-col h-full bg-gb-bg">
<div className="terminal-border border-t-0 border-x-0 px-3 py-2 text-gb-fg-s flex items-center justify-between">
<span> {channelName}</span>
<button onClick={() => setShowForm((p) => !p)} className="text-xs text-gb-fg-f hover:text-gb-orange font-mono">[NEW EVENT]</button>
</div>
{showForm && (
<div className="p-3 border-b border-gb-bg-t space-y-2 font-mono text-xs">
<input value={title} onChange={(e) => setTitle(e.target.value)} placeholder="title" className="terminal-input w-full" />
<input type="datetime-local" value={start} onChange={(e) => setStart(e.target.value)} className="terminal-input w-full" />
<input type="datetime-local" value={end} onChange={(e) => setEnd(e.target.value)} className="terminal-input w-full" />
<textarea value={description} onChange={(e) => setDescription(e.target.value)} placeholder="description" className="terminal-input w-full h-16" />
<button onClick={handleCreate} disabled={!title || !start} className="px-3 py-1 bg-gb-orange text-gb-bg disabled:opacity-50">[CREATE]</button>
</div>
)}
<div className="p-3 flex items-center justify-between font-mono text-xs">
<button onClick={prevMonth} className="text-gb-fg-f hover:text-gb-orange">[&lt;]</button>
<span className="text-gb-fg">{date.toLocaleString('default', { month: 'long', year: 'numeric' })}</span>
<button onClick={nextMonth} className="text-gb-fg-f hover:text-gb-orange">[&gt;]</button>
</div>
{loading && <div className="p-3 text-gb-fg-f text-xs font-mono">[loading...]</div>}
<div className="flex-1 overflow-y-auto p-3">
<div className="grid grid-cols-7 gap-1 text-center text-xs font-mono text-gb-fg-s mb-1">
{['S','M','T','W','T','F','S'].map((d) => <div key={d}>{d}</div>)}
</div>
<div className="grid grid-cols-7 gap-1">
{days.map((day, idx) => (
<div key={idx} className="min-h-16 border border-gb-bg-t p-1 text-xs">
{day !== null && (
<>
<div className="text-gb-fg-f font-mono">{day}</div>
{eventsForDay(day).map((ev) => (
<button
key={ev.id}
onClick={() => setSelectedEvent(ev)}
className="w-full text-left mt-1 px-1 py-0.5 truncate text-gb-bg font-mono"
style={{ backgroundColor: ev.color || '#b8bb26' }}
>
{ev.title}
</button>
))}
</>
)}
</div>
))}
</div>
</div>
{selectedEvent && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-gb-bg/90 p-4" onClick={() => setSelectedEvent(null)}>
<div className="bg-gb-bg border border-gb-fg-t w-full max-w-sm p-4" onClick={(e) => e.stopPropagation()}>
<div className="text-gb-fg font-bold mb-1">{selectedEvent.title}</div>
<div className="text-gb-fg-s text-xs font-mono mb-2">
{new Date(selectedEvent.start_time).toLocaleString()}
{selectedEvent.end_time && `${new Date(selectedEvent.end_time).toLocaleString()}`}
</div>
{selectedEvent.description && <div className="text-gb-fg-s text-xs mb-2">{selectedEvent.description}</div>}
<div className="flex gap-2 text-xs font-mono mb-3">
<span className="text-gb-green">going:{selectedEvent.going_count}</span>
<span className="text-gb-orange">maybe:{selectedEvent.maybe_count}</span>
<span className="text-gb-red">no:{selectedEvent.no_count}</span>
</div>
<div className="flex gap-2">
{(['going','maybe','no'] as const).map((s) => (
<button
key={s}
onClick={() => handleRSVP(selectedEvent.id, s)}
className={`px-2 py-1 border ${selectedEvent.user_status === s ? 'bg-gb-orange text-gb-bg border-gb-orange' : 'border-gb-bg-t text-gb-fg-s'}`}
>
{s}
</button>
))}
<button onClick={() => setSelectedEvent(null)} className="ml-auto text-gb-fg-f hover:text-gb-orange">[x]</button>
</div>
</div>
</div>
)}
</div>
);
}
+1 -1
View File
@@ -92,7 +92,7 @@ export function ChannelList() {
channel.id === activeChannelId ? 'terminal-active' : 'hover:bg-gb-bg-t text-gb-fg-s' channel.id === activeChannelId ? 'terminal-active' : 'hover:bg-gb-bg-t text-gb-fg-s'
}`} }`}
> >
<span className="text-gb-fg-f">{channel.type === 'forum' ? '■' : '#'}</span> <span className="text-gb-fg-f">{channel.type === 'forum' ? '■' : channel.type === 'calendar' ? '○' : '#'}</span>
<span className="truncate flex-1">{channel.name}</span> <span className="truncate flex-1">{channel.name}</span>
<span <span
onClick={(e) => { e.stopPropagation(); setSettingsChannel({ id: channel.id, name: channel.name }); }} onClick={(e) => { e.stopPropagation(); setSettingsChannel({ id: channel.id, name: channel.name }); }}
+5
View File
@@ -10,6 +10,7 @@ import { MessageSearch } from "./MessageSearch";
import { ThreadListPanel } from "./ThreadListPanel.tsx"; import { ThreadListPanel } from "./ThreadListPanel.tsx";
import { ThreadPanel } from "./ThreadPanel.tsx"; import { ThreadPanel } from "./ThreadPanel.tsx";
import { ForumView } from "./ForumView.tsx"; import { ForumView } from "./ForumView.tsx";
import { CalendarView } from "./CalendarView.tsx";
import { UserProfileModal } from "./UserProfileModal.tsx"; import { UserProfileModal } from "./UserProfileModal.tsx";
import ReactMarkdown from "react-markdown"; import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm"; import remarkGfm from "remark-gfm";
@@ -245,6 +246,8 @@ export function ChatArea() {
{activeChannel {activeChannel
? activeChannel.type === 'forum' ? activeChannel.type === 'forum'
? `${activeChannel.name}` ? `${activeChannel.name}`
: activeChannel.type === 'calendar'
? `${activeChannel.name}`
: `# ${activeChannel.name}` : `# ${activeChannel.name}`
: activeChannelId : activeChannelId
? `#${activeChannelId}` ? `#${activeChannelId}`
@@ -321,6 +324,8 @@ export function ChatArea() {
<div className="flex flex-1 min-h-0"> <div className="flex flex-1 min-h-0">
{activeChannel && activeChannel.type === 'forum' && activeChannelId ? ( {activeChannel && activeChannel.type === 'forum' && activeChannelId ? (
<ForumView channelId={activeChannelId} channelName={activeChannel.name} onOpenThread={(t) => setActiveThread(t)} /> <ForumView channelId={activeChannelId} channelName={activeChannel.name} onOpenThread={(t) => setActiveThread(t)} />
) : activeChannel && activeChannel.type === 'calendar' && activeChannelId ? (
<CalendarView channelId={activeChannelId} channelName={activeChannel.name} />
) : ( ) : (
<> <>
<div className="flex-1 flex flex-col min-w-0"> <div className="flex-1 flex flex-col min-w-0">
+4 -3
View File
@@ -11,7 +11,7 @@ interface ChannelApiResponse {
id: string; id: string;
server_id: string; server_id: string;
name: string; name: string;
type: 'text' | 'voice' | 'forum'; type: 'text' | 'voice' | 'forum' | 'calendar';
category: string; category: string;
position: number; position: number;
slowmode_seconds: number; slowmode_seconds: number;
@@ -29,7 +29,7 @@ const SLOWMODE_OPTIONS = [
export function CreateChannelModal({ serverId, onClose }: CreateChannelModalProps) { export function CreateChannelModal({ serverId, onClose }: CreateChannelModalProps) {
const [name, setName] = useState(''); const [name, setName] = useState('');
const [type, setType] = useState<'text' | 'voice' | 'forum'>('text'); const [type, setType] = useState<'text' | 'voice' | 'forum' | 'calendar'>('text');
const [category, setCategory] = useState('general'); const [category, setCategory] = useState('general');
const [slowmodeSeconds, setSlowmodeSeconds] = useState(0); const [slowmodeSeconds, setSlowmodeSeconds] = useState(0);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -107,12 +107,13 @@ export function CreateChannelModal({ serverId, onClose }: CreateChannelModalProp
<label className="text-xs text-gb-fg-f block mb-1">TYPE:</label> <label className="text-xs text-gb-fg-f block mb-1">TYPE:</label>
<select <select
value={type} value={type}
onChange={(e) => setType(e.target.value as 'text' | 'voice' | 'forum')} onChange={(e) => setType(e.target.value as 'text' | 'voice' | 'forum' | 'calendar')}
className="terminal-input w-full" className="terminal-input w-full"
> >
<option value="text">text</option> <option value="text">text</option>
<option value="voice">voice</option> <option value="voice">voice</option>
<option value="forum">forum</option> <option value="forum">forum</option>
<option value="calendar">calendar</option>
</select> </select>
</div> </div>
<div> <div>
+1 -1
View File
@@ -1,7 +1,7 @@
import { create } from 'zustand'; import { create } from 'zustand';
import { api } from '../lib/api.ts'; import { api } from '../lib/api.ts';
export type ChannelType = 'text' | 'voice' | 'forum'; export type ChannelType = 'text' | 'voice' | 'forum' | 'calendar';
export interface Channel { export interface Channel {
id: string; id: string;
+1 -1
View File
@@ -1 +1 @@
{"root":["./src/App.tsx","./src/main.tsx","./src/components/BotManager.tsx","./src/components/ChannelList.tsx","./src/components/ChannelSettingsModal.tsx","./src/components/ChatArea.tsx","./src/components/CommandManager.tsx","./src/components/ConversationList.tsx","./src/components/CreateChannelModal.tsx","./src/components/CreateServerModal.tsx","./src/components/DMChat.tsx","./src/components/EmojiPicker.tsx","./src/components/ForumView.tsx","./src/components/GiphyPicker.tsx","./src/components/InstallPrompt.tsx","./src/components/InviteModal.tsx","./src/components/JoinServer.tsx","./src/components/JoinServerModal.tsx","./src/components/Layout.tsx","./src/components/LoginForm.tsx","./src/components/MemberContextMenu.tsx","./src/components/MemberList.tsx","./src/components/MemberRoleAssign.tsx","./src/components/MentionDropdown.tsx","./src/components/MentionPopup.tsx","./src/components/MessageSearch.tsx","./src/components/MobileDrawer.tsx","./src/components/MobileNav.tsx","./src/components/NewConversationModal.tsx","./src/components/ReactionBar.tsx","./src/components/ReplyBar.tsx","./src/components/RoleManager.tsx","./src/components/ServerBar.tsx","./src/components/ServerSettingsModal.tsx","./src/components/SlashCommandPopup.tsx","./src/components/ThemeToggle.tsx","./src/components/ThreadListPanel.tsx","./src/components/ThreadPanel.tsx","./src/components/TypingIndicator.tsx","./src/components/UserProfileModal.tsx","./src/components/UserSettings.tsx","./src/components/VoiceChannel.tsx","./src/components/VoiceControls.tsx","./src/components/VoicePanel.tsx","./src/lib/api.ts","./src/lib/usePermissions.ts","./src/stores/auth.ts","./src/stores/bot.ts","./src/stores/channel.ts","./src/stores/conversation.ts","./src/stores/layout.ts","./src/stores/member.ts","./src/stores/message.ts","./src/stores/moderation.ts","./src/stores/permissions.ts","./src/stores/presence.ts","./src/stores/push.ts","./src/stores/role.ts","./src/stores/server.ts","./src/stores/thread.ts","./src/stores/typing.ts","./src/stores/voice.ts","./src/stores/ws.ts"],"version":"5.9.3"} {"root":["./src/App.tsx","./src/main.tsx","./src/components/BotManager.tsx","./src/components/CalendarView.tsx","./src/components/ChannelList.tsx","./src/components/ChannelSettingsModal.tsx","./src/components/ChatArea.tsx","./src/components/CommandManager.tsx","./src/components/ConversationList.tsx","./src/components/CreateChannelModal.tsx","./src/components/CreateServerModal.tsx","./src/components/DMChat.tsx","./src/components/EmojiPicker.tsx","./src/components/ForumView.tsx","./src/components/GiphyPicker.tsx","./src/components/InstallPrompt.tsx","./src/components/InviteModal.tsx","./src/components/JoinServer.tsx","./src/components/JoinServerModal.tsx","./src/components/Layout.tsx","./src/components/LoginForm.tsx","./src/components/MemberContextMenu.tsx","./src/components/MemberList.tsx","./src/components/MemberRoleAssign.tsx","./src/components/MentionDropdown.tsx","./src/components/MentionPopup.tsx","./src/components/MessageSearch.tsx","./src/components/MobileDrawer.tsx","./src/components/MobileNav.tsx","./src/components/NewConversationModal.tsx","./src/components/ReactionBar.tsx","./src/components/ReplyBar.tsx","./src/components/RoleManager.tsx","./src/components/ServerBar.tsx","./src/components/ServerSettingsModal.tsx","./src/components/SlashCommandPopup.tsx","./src/components/ThemeToggle.tsx","./src/components/ThreadListPanel.tsx","./src/components/ThreadPanel.tsx","./src/components/TypingIndicator.tsx","./src/components/UserProfileModal.tsx","./src/components/UserSettings.tsx","./src/components/VoiceChannel.tsx","./src/components/VoiceControls.tsx","./src/components/VoicePanel.tsx","./src/lib/api.ts","./src/lib/usePermissions.ts","./src/stores/auth.ts","./src/stores/bot.ts","./src/stores/channel.ts","./src/stores/conversation.ts","./src/stores/layout.ts","./src/stores/member.ts","./src/stores/message.ts","./src/stores/moderation.ts","./src/stores/permissions.ts","./src/stores/presence.ts","./src/stores/push.ts","./src/stores/role.ts","./src/stores/server.ts","./src/stores/thread.ts","./src/stores/typing.ts","./src/stores/voice.ts","./src/stores/ws.ts"],"version":"5.9.3"}