From 5469069d0a3f16789577f27462eee9902e447e91 Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Mon, 24 Apr 2023 23:21:18 +0200 Subject: [PATCH] bugfix in chat.js --- static/js/chat.js | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/static/js/chat.js b/static/js/chat.js index 2b74de6d..bc10aacc 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -88,10 +88,6 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) { waitAnimation.style.display = "block"; stopGeneration.style.display = "block"; - // local stuff - let messageTextElement_ = undefined - let hiddenElement_ = undefined - elements = addMessage("", "", 0, 0, can_edit = true); // scroll to bottom of chat window chatWindow.scrollTop = chatWindow.scrollHeight; @@ -144,8 +140,6 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) { infos = JSON.parse(text) elements.setID(infos.response_id) elements.setSender(infos.bot) - messageTextElement_ = elements['messageTextElement']; - hiddenElement_ = elements['hiddenElement']; entry_counter++; } else { @@ -154,22 +148,17 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) { if(text.startsWith(prefix)){ console.log("Final text found") text = text.substring(prefix.length); - hiddenElement.innerHTML = text - messageTextElement.innerHTML = text + elements.hiddenElement.innerHTML = text + elements.messageTextElement.innerHTML = text } else{ // For the other enrtries, these are just the text of the chatbot - for (const char of text) { - txt = hiddenElement_.innerHTML; - if (char != '\f') { - txt += char - hiddenElement_.innerHTML = txt - messageTextElement_.innerHTML = txt - } - - // scroll to bottom of chat window - chatWindow.scrollTop = chatWindow.scrollHeight; - } + txt = hiddenElement_.innerHTML; + txt += text + elements.hiddenElement.innerHTML = txt + elements.messageTextElement.innerHTML = txt + // scroll to bottom of chat window + chatWindow.scrollTop = chatWindow.scrollHeight; } }