Fix delete message without checkboxes

This commit is contained in:
Cohee 2023-11-15 00:27:46 +02:00
parent f24aae546c
commit 9bef9f4332
1 changed files with 22 additions and 17 deletions

View File

@ -654,7 +654,7 @@ let api_server_textgenerationwebui = "";
let is_send_press = false; //Send generation let is_send_press = false; //Send generation
let this_del_mes = 0; let this_del_mes = -1;
//message editing and chat scroll position persistence //message editing and chat scroll position persistence
var this_edit_mes_text = ""; var this_edit_mes_text = "";
@ -5548,6 +5548,7 @@ function openMessageDelete(fromSlashCommand) {
selected_group: ${selected_group} selected_group: ${selected_group}
is_group_generating: ${is_group_generating}`); is_group_generating: ${is_group_generating}`);
} }
this_del_mes = -1;
is_delete_mode = true; is_delete_mode = true;
} }
@ -8169,9 +8170,8 @@ jQuery(async function () {
$(this).parent().css("background", css_mes_bg); $(this).parent().css("background", css_mes_bg);
$(this).prop("checked", false); $(this).prop("checked", false);
}); });
this_del_mes = 0;
console.debug('canceled del msgs, calling showswipesbtns');
showSwipeButtons(); showSwipeButtons();
this_del_mes = -1;
is_delete_mode = false; is_delete_mode = false;
}); });
@ -8185,21 +8185,26 @@ jQuery(async function () {
$(this).parent().css("background", css_mes_bg); $(this).parent().css("background", css_mes_bg);
$(this).prop("checked", false); $(this).prop("checked", false);
}); });
$(".mes[mesid='" + this_del_mes + "']")
.nextAll("div") if (this_del_mes >= 0) {
.remove(); $(".mes[mesid='" + this_del_mes + "']")
$(".mes[mesid='" + this_del_mes + "']").remove(); .nextAll("div")
chat.length = this_del_mes; .remove();
count_view_mes = this_del_mes; $(".mes[mesid='" + this_del_mes + "']").remove();
await saveChatConditional(); chat.length = this_del_mes;
var $textchat = $("#chat"); count_view_mes = this_del_mes;
$textchat.scrollTop($textchat[0].scrollHeight); await saveChatConditional();
eventSource.emit(event_types.MESSAGE_DELETED, chat.length); var $textchat = $("#chat");
this_del_mes = 0; $textchat.scrollTop($textchat[0].scrollHeight);
$('#chat .mes').last().addClass('last_mes'); eventSource.emit(event_types.MESSAGE_DELETED, chat.length);
$('#chat .mes').eq(-2).removeClass('last_mes'); $('#chat .mes').last().addClass('last_mes');
console.debug('confirmed del msgs, calling showswipesbtns'); $('#chat .mes').eq(-2).removeClass('last_mes');
} else {
console.log('this_del_mes is not >= 0, not deleting');
}
showSwipeButtons(); showSwipeButtons();
this_del_mes = -1;
is_delete_mode = false; is_delete_mode = false;
}); });