Message delete highlight color follows theme settings

This commit is contained in:
Cohee 2024-05-11 17:17:42 +03:00
parent e73b5713fd
commit 6a4ee68113
2 changed files with 16 additions and 18 deletions

View File

@ -789,7 +789,6 @@ export let novelai_setting_names;
let abortController; let abortController;
//css //css
var css_mes_bg = $('<div class="mes"></div>').css('background');
var css_send_form_display = $('<div id=send_form></div>').css('display'); var css_send_form_display = $('<div id=send_form></div>').css('display');
const MAX_GENERATION_LOOPS = 5; const MAX_GENERATION_LOOPS = 5;
@ -8586,19 +8585,17 @@ jQuery(async function () {
} }
$('.mes').children('.del_checkbox').each(function () { $('.mes').children('.del_checkbox').each(function () {
$(this).prop('checked', false); $(this).prop('checked', false);
$(this).parent().css('background', css_mes_bg); $(this).parent().removeClass('selected');
}); });
$(this).css('background', '#600'); //sets the bg of the mes selected for deletion $(this).addClass('selected'); //sets the bg of the mes selected for deletion
var i = Number($(this).attr('mesid')); //checks the message ID in the chat var i = Number($(this).attr('mesid')); //checks the message ID in the chat
this_del_mes = i; this_del_mes = i;
while (i < chat.length) {
//as long as the current message ID is less than the total chat length //as long as the current message ID is less than the total chat length
$('.mes[mesid=\'' + i + '\']').css('background', '#600'); //sets the bg of the all msgs BELOW the selected .mes while (i < chat.length) {
$('.mes[mesid=\'' + i + '\']') //sets the bg of the all msgs BELOW the selected .mes
.children('.del_checkbox') $(`.mes[mesid="${i}"]`).addClass('selected');
.prop('checked', true); $(`.mes[mesid="${i}"]`).children('.del_checkbox').prop('checked', true);
i++; i++;
//console.log(i);
} }
}); });
@ -9202,7 +9199,7 @@ jQuery(async function () {
$('.del_checkbox').each(function () { $('.del_checkbox').each(function () {
$(this).css('display', 'none'); $(this).css('display', 'none');
$(this).parent().children('.for_checkbox').css('display', 'block'); $(this).parent().children('.for_checkbox').css('display', 'block');
$(this).parent().css('background', css_mes_bg); $(this).parent().removeClass('selected');
$(this).prop('checked', false); $(this).prop('checked', false);
}); });
showSwipeButtons(); showSwipeButtons();
@ -9217,22 +9214,19 @@ jQuery(async function () {
$('.del_checkbox').each(function () { $('.del_checkbox').each(function () {
$(this).css('display', 'none'); $(this).css('display', 'none');
$(this).parent().children('.for_checkbox').css('display', 'block'); $(this).parent().children('.for_checkbox').css('display', 'block');
$(this).parent().css('background', css_mes_bg); $(this).parent().removeClass('selected');
$(this).prop('checked', false); $(this).prop('checked', false);
}); });
if (this_del_mes >= 0) { if (this_del_mes >= 0) {
$('.mes[mesid=\'' + this_del_mes + '\']') $(`.mes[mesid="${this_del_mes}"]`).nextAll('div').remove();
.nextAll('div') $(`.mes[mesid="${this_del_mes}"]`).remove();
.remove();
$('.mes[mesid=\'' + this_del_mes + '\']').remove();
chat.length = this_del_mes; chat.length = this_del_mes;
await saveChatConditional(); await saveChatConditional();
var $textchat = $('#chat'); chatElement.scrollTop(chatElement[0].scrollHeight);
$textchat.scrollTop($textchat[0].scrollHeight);
eventSource.emit(event_types.MESSAGE_DELETED, chat.length); eventSource.emit(event_types.MESSAGE_DELETED, chat.length);
$('#chat .mes').removeClass('last_mes');
$('#chat .mes').last().addClass('last_mes'); $('#chat .mes').last().addClass('last_mes');
$('#chat .mes').eq(-2).removeClass('last_mes');
} else { } else {
console.log('this_del_mes is not >= 0, not deleting'); console.log('this_del_mes is not >= 0, not deleting');
} }

View File

@ -813,6 +813,10 @@ body .panelControlBar {
position: relative; position: relative;
} }
#chat .mes.selected{
background-color: rgb(from var(--SmartThemeQuoteColor) r g b / .5);
}
.mes q:before, .mes q:before,
.mes q:after { .mes q:after {
content: ''; content: '';