From 75fee7c725eed55b40eac9525bcc085f45e5a4dd Mon Sep 17 00:00:00 2001 From: nav Date: Thu, 14 May 2026 16:49:57 +0000 Subject: [PATCH] fix(frontend): require guildId for channel creation and fallback from channel list --- src/pages/ChatPage.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/ChatPage.tsx b/src/pages/ChatPage.tsx index 290b5b3..d8b11cb 100644 --- a/src/pages/ChatPage.tsx +++ b/src/pages/ChatPage.tsx @@ -10,7 +10,7 @@ type MessageItem = { isDeleted?: boolean } -type GuildChannel = { id: string; name: string } +type GuildChannel = { id: string; name: string; guildId?: string } type GuildRecord = { id: string; name: string } type GuildMember = { id: string; userId: string; guildId: string; status: string } @@ -69,6 +69,7 @@ export default function ChatPage() { }) const list = Array.isArray(res.data) ? (res.data as GuildChannel[]) : [] setChannels(list) + if (!guildDbId && list[0]?.guildId) setGuildDbId(list[0].guildId) if (!selectedChannelId && list.length) setSelectedChannelId(list[0].id) } catch { setError('Failed to load channels') @@ -129,10 +130,13 @@ export default function ChatPage() { async function createChannel() { if (!guild || !guildToken || !newChannelName.trim()) return + if (!guildDbId) { + setError('Cannot create channel: guildId is missing') + return + } setError('') try { - const payload = guildDbId ? { name: newChannelName.trim(), guildId: guildDbId } : { name: newChannelName.trim() } - const res = await guildApi().post('/channels', payload) + const res = await guildApi().post('/channels', { name: newChannelName.trim(), guildId: guildDbId }) const createdId = res.data?.id as string | undefined setNewChannelName('') await loadChannels()