Fixed: site cannot open if imported json invalid (#579)

This commit is contained in:
KhanKudo
2023-04-18 16:18:08 +02:00
committed by GitHub
parent 1146f9a86e
commit 9e4c5ca4ff
+13
View File
@@ -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;
@@ -41,6 +42,13 @@ export const cleanSelectedConversation = (conversation: Conversation) => {
};
}
if (!updatedConversation.messages) {
updatedConversation = {
...updatedConversation,
messages: updatedConversation.messages || [],
};
}
return updatedConversation;
};
@@ -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.');
@@ -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) {