Skip to content

Commit

Permalink
fix: proper replacing messages with ids
Browse files Browse the repository at this point in the history
  • Loading branch information
avarayr committed Sep 20, 2024
1 parent 5f4d712 commit 3b11086
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/server/models/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export const Chat = {
},

async replaceMessages(chatId: string, messages: TMessageWithID[]) {
await db.ref(`chats/${chatId}/messages`).set(messages);
const messagesWithIds = Object.fromEntries(messages.map((message) => [message.id, message]));
await db.ref(`chats/${chatId}/messages`).set(messagesWithIds);
},
};

0 comments on commit 3b11086

Please sign in to comment.