fix /delchat for characters with lots of chat files

This commit is contained in:
Juha Jeronen 2024-02-07 15:20:37 +02:00
parent 2815990589
commit f0cffb3dd9
1 changed files with 14 additions and 15 deletions

View File

@ -7817,15 +7817,11 @@ async function doImpersonate() {
}
async function doDeleteChat() {
$('#option_select_chat').trigger('click', { fromSlashCommand: true });
await delay(100);
await displayPastChats();
let currentChatDeleteButton = $('.select_chat_block[highlight=\'true\']').parent().find('.PastChat_cross');
$(currentChatDeleteButton).trigger('click', { fromSlashCommand: true });
$(currentChatDeleteButton).trigger('click');
await delay(1);
$('#dialogue_popup_ok').trigger('click');
//200 delay needed let the past chat view reshow first
await delay(200);
$('#select_chat_cross').trigger('click');
$('#dialogue_popup_ok').trigger('click', { fromSlashCommand: true });
}
const isPwaMode = window.navigator.standalone;
@ -8208,7 +8204,8 @@ jQuery(async function () {
$('#character_popup').css('display', 'none');
});
$('#dialogue_popup_ok').click(async function (e) {
$('#dialogue_popup_ok').click(async function (e, customData) {
const fromSlashCommand = customData?.fromSlashCommand || false;
dialogueCloseStop = false;
$('#shadow_popup').transition({
opacity: 0,
@ -8238,14 +8235,16 @@ jQuery(async function () {
await delChat(chat_file_for_del);
}
//open the history view again after 2seconds (delay to avoid edge cases for deleting last chat)
//hide option popup menu
if (fromSlashCommand) { // When called from `/delchat` command, don't re-open the history view.
$('#options').hide(); // hide option popup menu
hideLoader();
} else { // Open the history view again after 2 seconds (delay to avoid edge cases for deleting last chat).
setTimeout(function () {
$('#option_select_chat').click();
$('#options').hide();
$('#options').hide(); // hide option popup menu
hideLoader();
}, 2000);
}
}
if (popup_type == 'del_ch') {
const deleteChats = !!$('#del_char_checkbox').prop('checked');