Skip to content

Commit

Permalink
Fixed: site cannot open if imported json invalid (mckaywrigley#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhanKudo authored Apr 18, 2023
1 parent 1146f9a commit 9e4c5ca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/app/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const cleanSelectedConversation = (conversation: Conversation) => {
// added system prompt for each conversation (3/21/23)
// added folders (3/23/23)
// added prompts (3/26/23)
// added messages (4/16/23)

let updatedConversation = conversation;

Expand Down Expand Up @@ -41,6 +42,13 @@ export const cleanSelectedConversation = (conversation: Conversation) => {
};
}

if (!updatedConversation.messages) {
updatedConversation = {
...updatedConversation,
messages: updatedConversation.messages || [],
};
}

return updatedConversation;
};

Expand All @@ -49,6 +57,7 @@ export const cleanConversationHistory = (history: any[]): Conversation[] => {
// added system prompt for each conversation (3/21/23)
// added folders (3/23/23)
// added prompts (3/26/23)
// added messages (4/16/23)

if (!Array.isArray(history)) {
console.warn('history is not an array. Returning an empty array.');
Expand All @@ -73,6 +82,10 @@ export const cleanConversationHistory = (history: any[]): Conversation[] => {
conversation.folderId = null;
}

if (!conversation.messages) {
conversation.messages = [];
}

acc.push(conversation);
return acc;
} catch (error) {
Expand Down

0 comments on commit 9e4c5ca

Please sign in to comment.