remove dom queries and jQuery during streaming
This commit is contained in:
parent
f3cfc4c3c9
commit
ded6536b06
|
@ -2797,6 +2797,10 @@ class StreamingProcessor {
|
||||||
constructor(type, force_name2, timeStarted, messageAlreadyGenerated) {
|
constructor(type, force_name2, timeStarted, messageAlreadyGenerated) {
|
||||||
this.result = '';
|
this.result = '';
|
||||||
this.messageId = -1;
|
this.messageId = -1;
|
||||||
|
this.messageDom = null;
|
||||||
|
this.messageTextDom = null;
|
||||||
|
this.messageTimerDom = null;
|
||||||
|
this.sendTextarea = document.querySelector('#send_textarea');
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.force_name2 = force_name2;
|
this.force_name2 = force_name2;
|
||||||
this.isStopped = false;
|
this.isStopped = false;
|
||||||
|
@ -2833,11 +2837,15 @@ class StreamingProcessor {
|
||||||
let messageId = -1;
|
let messageId = -1;
|
||||||
|
|
||||||
if (this.type == 'impersonate') {
|
if (this.type == 'impersonate') {
|
||||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
|
this.sendTextarea.value = '';
|
||||||
|
this.sendTextarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await saveReply(this.type, text, true);
|
await saveReply(this.type, text, true);
|
||||||
messageId = chat.length - 1;
|
messageId = chat.length - 1;
|
||||||
|
this.messageDom = document.querySelector(`#chat .mes[mesid="${messageId}"]`);
|
||||||
|
this.messageTextDom = this.messageDom.querySelector('.mes_text');
|
||||||
|
this.messageTimerDom = this.messageDom.querySelector('.mes_timer');
|
||||||
this.showMessageButtons(messageId);
|
this.showMessageButtons(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2869,7 +2877,8 @@ class StreamingProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isImpersonate) {
|
if (isImpersonate) {
|
||||||
$('#send_textarea').val(processedText)[0].dispatchEvent(new Event('input', { bubbles: true }));
|
this.sendTextarea.value = processedText;
|
||||||
|
this.sendTextarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let currentTime = new Date();
|
let currentTime = new Date();
|
||||||
|
@ -2902,9 +2911,9 @@ class StreamingProcessor {
|
||||||
chat[messageId].is_user,
|
chat[messageId].is_user,
|
||||||
messageId,
|
messageId,
|
||||||
);
|
);
|
||||||
const mesText = $(`#chat .mes[mesid="${messageId}"] .mes_text`);
|
this.messageTextDom.innerHTML = formattedText;
|
||||||
mesText.html(formattedText);
|
this.messageTimerDom.textContent = timePassed.timerValue;
|
||||||
$(`#chat .mes[mesid="${messageId}"] .mes_timer`).text(timePassed.timerValue).attr('title', timePassed.timerTitle);
|
this.messageTimerDom.title = timePassed.timerTitle;
|
||||||
this.setFirstSwipe(messageId);
|
this.setFirstSwipe(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue