Skip to content

Commit

Permalink
fix: prevent double saving messages (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyphilemon authored Feb 7, 2025
1 parent 8bf5bf6 commit 93068bf
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions app/(chat)/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export async function POST(request: Request) {
return new Response('No user message found', { status: 400 });
}

const userMessageId = generateUUID();

if (session?.user?.id) {
const chat = await getChatById({ id });

Expand All @@ -66,17 +64,6 @@ export async function POST(request: Request) {
await saveChat({ id, userId: session.user.id, title });
}

await saveMessages({
messages: [
{
...userMessage,
id: userMessageId,
createdAt: new Date(),
chatId: id,
},
],
});

await saveMessages({
messages: [{ ...userMessage, createdAt: new Date(), chatId: id }],
});
Expand Down

0 comments on commit 93068bf

Please sign in to comment.