From f6ed23d29d93a5207494643c449ad32a36e695ed Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 16:45:09 +0300 Subject: [PATCH] Fix swipe on first message when streaming is on --- public/script.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 1b16ac562..511af7cfe 100644 --- a/public/script.js +++ b/public/script.js @@ -1231,6 +1231,7 @@ class StreamingProcessor { let formattedText = messageFormating(processedText, chat[messageId].name, chat[messageId].is_system, chat[messageId].force_avatar); const mesText = $(`#chat .mes[mesid="${messageId}"] .mes_text`); mesText.html(formattedText); + this.setFirstSwipe(messageId); } scrollChatToBottom(); @@ -1257,6 +1258,14 @@ class StreamingProcessor { showSwipeButtons(); } + setFirstSwipe(messageId) { + if (this.type !== 'swipe' && this.type !== 'impersonate') { + if (chat[messageId]['swipes'].length === 1 && chat[messageId]['swipe_id'] === 0) { + chat[messageId]['swipes'][0] = chat[messageId]['mes']; + } + } + } + onStopStreaming() { this.onErrorStreaming(); } @@ -1274,11 +1283,12 @@ class StreamingProcessor { this.isFinished = false; this.generator = this.nullStreamingGeneration; this.abortController = new AbortController(); + this.firstMessageText = '...'; } async generate() { if (this.messageId == -1) { - this.messageId = this.onStartStreaming('...'); + this.messageId = this.onStartStreaming(this.firstMessageText); await delay(1); // delay for message to be rendered } @@ -1327,6 +1337,7 @@ async function Generate(type, automatic_trigger, force_name2) { if (isStreamingEnabled()) { streamingProcessor = new StreamingProcessor(type, force_name2); + hideSwipeButtons(); } else { streamingProcessor = false;