diff --git a/src/routes/messages.index.tsx b/src/routes/messages.index.tsx index 757acbf..36d0ffe 100644 --- a/src/routes/messages.index.tsx +++ b/src/routes/messages.index.tsx @@ -298,14 +298,13 @@ function NewConversationDialog({ profiles, onCreated }: { profiles: Profile[]; o } setBusy(true); try { - const { data: conv, error } = await supabase + const convId = crypto.randomUUID(); + const { error } = await supabase .from("conversations") - .insert({ type, name: type === "channel" ? name.trim() : null, created_by: user.id }) - .select("id") - .single(); - if (error || !conv) throw error; + .insert({ id: convId, type, name: type === "channel" ? name.trim() : null, created_by: user.id }); + if (error) throw error; const memberRows = [user.id, ...Array.from(selected)].map((uid) => ({ - conversation_id: conv.id, + conversation_id: convId, user_id: uid, })); const { error: mErr } = await supabase.from("conversation_members").insert(memberRows); @@ -313,7 +312,7 @@ function NewConversationDialog({ profiles, onCreated }: { profiles: Profile[]; o toast.success("Conversation created"); setOpen(false); reset(); - onCreated(conv.id); + onCreated(convId); } catch (e: any) { toast.error(e.message || "Failed to create conversation"); } finally {