mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Chat deletion should actually work
This commit is contained in:
@ -700,19 +700,51 @@ async function delChat(chatfile) {
|
|||||||
//close past chat popup
|
//close past chat popup
|
||||||
$("#select_chat_cross").click();
|
$("#select_chat_cross").click();
|
||||||
|
|
||||||
//this is a copy of what 'start new chat' does, just without the popup and confirmation
|
// choose another chat if current was deleted
|
||||||
//not an ideal solution, and needs to be smarter
|
if (chatfile.replace('.jsonl', '') === characters[this_chid].chat) {
|
||||||
|
await replaceCurrentChat();
|
||||||
|
}
|
||||||
|
|
||||||
|
//open the history view again after 100ms
|
||||||
|
//hide option popup menu
|
||||||
|
setTimeout(function () {
|
||||||
|
$("#option_select_chat").click();
|
||||||
|
$("#options").hide();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function replaceCurrentChat() {
|
||||||
clearChat();
|
clearChat();
|
||||||
chat.length = 0;
|
chat.length = 0;
|
||||||
|
|
||||||
|
const chatsResponse = await fetch("/getallchatsofcharacter", {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
"X-CSRF-Token": token,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ avatar_url: characters[this_chid].avatar })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (chatsResponse.ok) {
|
||||||
|
const chats = Object.values(await chatsResponse.json());
|
||||||
|
|
||||||
|
// pick existing chat
|
||||||
|
if (chats.length && typeof chats[0] === 'object') {
|
||||||
|
characters[this_chid].chat = chats[0].file_name.replace('.jsonl', '');
|
||||||
|
$("#selected_chat_pole").val(characters[this_chid].chat);
|
||||||
|
saveCharacterDebounced();
|
||||||
|
await getChat();
|
||||||
|
}
|
||||||
|
|
||||||
|
// start new chat
|
||||||
|
else {
|
||||||
characters[this_chid].chat = name2 + " - " + humanizedDateTime();
|
characters[this_chid].chat = name2 + " - " + humanizedDateTime();
|
||||||
$("#selected_chat_pole").val(characters[this_chid].chat);
|
$("#selected_chat_pole").val(characters[this_chid].chat);
|
||||||
saveCharacterDebounced();
|
saveCharacterDebounced();
|
||||||
getChat();
|
await getChat();
|
||||||
|
}
|
||||||
//open the history view again after 100ms
|
|
||||||
setTimeout(function () { $("#option_select_chat").click() }, 100);
|
|
||||||
//hide option popup menu
|
|
||||||
$("#options").hide();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user