From 950838253dc9290261230a2df60e5bede7b13889 Mon Sep 17 00:00:00 2001 From: somebody Date: Fri, 18 Nov 2022 18:20:15 -0600 Subject: [PATCH] Order fix and focus fix for wi thing We previously had action ids as strings, and sorting them had unexpected behavior (1, 10, 2) --- static/koboldai.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index 17f10802..c3520c2d 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2187,7 +2187,7 @@ function world_info_entry(data) { autoResize(manual_text, 60); //put focus back where it was - if (document.getElementById(original_focus)) { + if (original_focus && document.getElementById(original_focus)) { if (document.getElementById(original_focus).tagName != "BUTTON") { //check if we were on a new line if ((on_new_wi_item != null) && (document.getElementById(on_new_wi_item))) { @@ -6093,7 +6093,8 @@ function updateChatStyle() { let addedMessages = 0; - for (const [chunkId, chunk] of Object.entries(actions_data).sort((a, b) => a[0].localeCompare(b[0]))) { + for (let [chunkId, chunk] of Object.entries(actions_data).sort((a, b) => parseInt(a) > parseInt(b))) { + chunkId = parseInt(chunkId); for (const message of parseChatMessages(chunk["Selected Text"])) { // JS Time uses milliseconds, thus the * 1000 addMessage(message.author, message.text, chunkId, null, chunk["Time"] * 1000);