From c77e937aef9d78f72c61003667b3abd882c0f57a Mon Sep 17 00:00:00 2001 From: somebody Date: Fri, 14 Oct 2022 13:57:33 -0500 Subject: [PATCH] Fix theme stuff We now wait for CSS to load before reading it and such --- static/koboldai.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index 057b2ef8..bd06acf8 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2652,9 +2652,13 @@ function calc_token_usage( function Change_Theme(theme) { var css = document.getElementById("CSSTheme"); css.setAttribute("href", "/themes/"+theme+".css"); - setTimeout(() => { + + // We must wait for the style to load before we read it + css.onload = function() { + recolorTokens(); create_theming_elements(); - }, "1000") + } + setCookie("theme", theme); select = document.getElementById("selected_theme"); for (element of select.childNodes) { @@ -2664,7 +2668,6 @@ function Change_Theme(theme) { element.selected = false; } } - recolorTokens(); } function palette_color(item) {