Skip to content

Commit

Permalink
pass db to formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work committed Sep 5, 2024
1 parent 6268720 commit 5e1c4aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/contexts/ConversationLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const fetchConversation = (db: IDBDatabase, conversationId: string) => {
});
};

const formatConversation = (conversation: Conversation) => {
const formatConversation = (conversation: Conversation, db: IDBDatabase) => {
const conversationCopy = Object.assign({}, conversation);
conversationCopy.title = getConversationTitle(conversation);
delete conversationCopy.messages; // reduce memory usage
Expand All @@ -88,7 +88,7 @@ const fetchAllConversations = (
.filter(
(c: Conversation) => c.user_id === user_id && c.bot_id === bot_id
)
.map(formatConversation);
.map((c) => formatConversation(c, db));

resolve(userConversations);
};
Expand All @@ -115,7 +115,7 @@ const addConversation = (db: IDBDatabase, conversation: Conversation) => {
c.user_id === conversation.user_id &&
c.bot_id === conversation.bot_id
)
.map(formatConversation)
.map((c) => formatConversation(c, db))
);
};
allObjectsReq.onerror = () => {
Expand Down

0 comments on commit 5e1c4aa

Please sign in to comment.