Fix deletion and smooth indicator

This commit is contained in:
SillyLossy
2023-02-27 21:15:35 +02:00
parent f215ff664e
commit 1b8b8f0f37

View File

@@ -1756,8 +1756,6 @@
} }
}); });
async function generateGroupWrapper() { async function generateGroupWrapper() {
$('#chat .typing_indicator').remove();
if (online_status === 'no_connection') { if (online_status === 'no_connection') {
is_group_generating = false; is_group_generating = false;
is_send_press = false; is_send_press = false;
@@ -1783,17 +1781,27 @@
messagesBefore++; messagesBefore++;
} }
let typingIndicator = $('#chat .typing_indicator');
if (typingIndicator.length === 0){
typingIndicator = $('#typing_indicator_template .typing_indicator').clone();
typingIndicator.hide();
$('#chat').append(typingIndicator);
}
// now the real generation begins: cycle through every character // now the real generation begins: cycle through every character
for (const chId of activatedMembers) { for (const chId of activatedMembers) {
this_chid = chId; this_chid = chId;
name2 = characters[chId].name; name2 = characters[chId].name;
const typingIndicator = $('#typing_indicator_template .typing_indicator').clone();
typingIndicator.find('.typing_indicator_name').text(characters[chId].name);
await Generate('group_chat'); await Generate('group_chat');
// update indicator and scroll down
typingIndicator.find('.typing_indicator_name').text(characters[chId].name);
$('#chat').append(typingIndicator); $('#chat').append(typingIndicator);
typingIndicator.fadeTo(250, 1, function() {
typingIndicator.get(0).scrollIntoView({behavior: 'smooth'});
});
while (true) { while (true) {
// check if message generated already // check if message generated already
@@ -1805,13 +1813,14 @@
} }
} }
$('#chat .typing_indicator').remove(); // hide and reapply the indicator to the bottom of the list
typingIndicator.fadeTo(250, 0);
$('#chat').append(typingIndicator);
} }
} finally { } finally {
is_group_generating = false; is_group_generating = false;
is_send_press = false; is_send_press = false;
$('#chat .typing_indicator').remove();
} }
} }
function activateMembers(members, input) { function activateMembers(members, input) {
@@ -2867,7 +2876,7 @@
}); });
// this function hides the input form, and shows the delete/cancel buttons fro deleting messages from chat // this function hides the input form, and shows the delete/cancel buttons fro deleting messages from chat
$( "#option_delete_mes" ).click(function() { $( "#option_delete_mes" ).click(function() {
if(this_chid != undefined && !is_send_press){ if(this_chid != undefined && !is_send_press || (selected_group && !is_group_generating)){
$('#dialogue_del_mes').css('display','block'); $('#dialogue_del_mes').css('display','block');
$('#send_form').css('display','none'); $('#send_form').css('display','none');
$('.del_checkbox').each(function(){ $('.del_checkbox').each(function(){
@@ -2909,7 +2918,11 @@
$(".mes[mesid='"+this_del_mes+"']").remove(); $(".mes[mesid='"+this_del_mes+"']").remove();
chat.length = this_del_mes; chat.length = this_del_mes;
count_view_mes = this_del_mes; count_view_mes = this_del_mes;
saveChat(); if (selected_group) {
saveGroupChat(selected_group);
} else {
saveChat();
}
var $textchat = $('#chat'); var $textchat = $('#chat');
$textchat.scrollTop($textchat[0].scrollHeight); $textchat.scrollTop($textchat[0].scrollHeight);
} }