Save a backup before deleting from new chat menu

This commit is contained in:
Cohee 2024-03-27 20:43:40 +02:00
parent 45bd8c18ed
commit 9bd1d79f08

View File

@ -8603,8 +8603,13 @@ jQuery(async function () {
await clearChat(); await clearChat();
chat.length = 0; chat.length = 0;
chat_file_for_del = getCurrentChatDetails().sessionName; chat_file_for_del = getCurrentChatDetails()?.sessionName;
const isDelChatCheckbox = document.getElementById('del_chat_checkbox').checked; const isDelChatCheckbox = document.getElementById('del_chat_checkbox')?.checked;
// Make it easier to find in backups
if (isDelChatCheckbox) {
await saveChatConditional();
}
if (selected_group) { if (selected_group) {
//Fix it; When you're creating a new group chat (but not when initially converting from the existing regular chat), the first greeting message doesn't automatically get translated. //Fix it; When you're creating a new group chat (but not when initially converting from the existing regular chat), the first greeting message doesn't automatically get translated.
@ -8670,14 +8675,13 @@ jQuery(async function () {
$('#form_create').submit(createOrEditCharacter); $('#form_create').submit(createOrEditCharacter);
$('#delete_button').on('click', function () { $('#delete_button').on('click', function () {
popup_type = 'del_ch';
callPopup(` callPopup(`
<h3>Delete the character?</h3> <h3>Delete the character?</h3>
<b>THIS IS PERMANENT!<br><br> <b>THIS IS PERMANENT!<br><br>
<label for="del_char_checkbox" class="checkbox_label justifyCenter"> <label for="del_char_checkbox" class="checkbox_label justifyCenter">
<input type="checkbox" id="del_char_checkbox" /> <input type="checkbox" id="del_char_checkbox" />
<span>Also delete the chat files</span> <small>Also delete the chat files</small>
</label><br></b>`, </label><br></b>`, 'del_ch', '',
); );
}); });
@ -8985,7 +8989,7 @@ jQuery(async function () {
<label for="del_chat_checkbox" class="checkbox_label justifyCenter" <label for="del_chat_checkbox" class="checkbox_label justifyCenter"
title="If necessary, you can later restore this chat file from the /backups folder"> title="If necessary, you can later restore this chat file from the /backups folder">
<input type="checkbox" id="del_chat_checkbox" /> <input type="checkbox" id="del_chat_checkbox" />
<span>Also delete the current chat file</span> <small>Also delete the current chat file</small>
</label><br> </label><br>
`, 'new_chat', ''); `, 'new_chat', '');
} }