fix delete 1 chat

This commit is contained in:
2023-03-14 22:14:10 +08:00
parent ba363c0a63
commit 711b9d48a1

View File

@@ -181,13 +181,16 @@ export function App() {
if (!confirm("Are you sure you want to delete this chat history?"))
return;
const oldAPIkey = allChatStore[selectedChatIndex].apiKey;
const oldSystemMessageContent =
allChatStore[selectedChatIndex].systemMessageContent;
const oldAPIEndpoint = allChatStore[selectedChatIndex].apiEndpoint;
allChatStore.splice(selectedChatIndex, 1);
if (allChatStore.length === 0) {
allChatStore.push(
newChatStore(
oldAPIkey,
allChatStore[selectedChatIndex].systemMessageContent,
allChatStore[selectedChatIndex].apiEndpoint
defaultAPIKEY() || oldAPIkey,
defaultSysMessage() || oldSystemMessageContent,
defaultAPIEndpoint() || oldAPIEndpoint
)
);
setSelectedChatIndex(0);