From 3e3597673b7ada94625b1d1d0cade994c690fc07 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:22:54 +0300 Subject: [PATCH] Less horrible charListGrid load --- public/script.js | 5 ++--- public/scripts/power-user.js | 15 +++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/public/script.js b/public/script.js index 6e25210ff..0228f9811 100644 --- a/public/script.js +++ b/public/script.js @@ -8879,9 +8879,8 @@ const isPwaMode = window.navigator.standalone; if (isPwaMode) { $('body').addClass('PWA'); } function doCharListDisplaySwitch() { - console.debug('toggling body charListGrid state'); - $('body').toggleClass('charListGrid'); - power_user.charListGrid = $('body').hasClass('charListGrid') ? true : false; + power_user.charListGrid = !power_user.charListGrid; + document.body.classList.toggle('charListGrid', power_user.charListGrid); saveSettingsDebounced(); } diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 2eb7aaf11..06c0c3921 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -106,6 +106,7 @@ export const persona_description_positions = { }; let power_user = { + charListGrid: false, tokenizer: tokenizers.BEST_MATCH, token_padding: 64, collapse_newlines: false, @@ -1602,18 +1603,8 @@ async function loadPowerUserSettings(settings, data) { loadCharListState(); } -async function loadCharListState() { - if (document.querySelector('.character_select') !== null) { - console.debug('setting charlist state to...'); - if (power_user.charListGrid === true) { - console.debug('..to grid'); - $('#charListGridToggle').trigger('click'); - } else { console.debug('..to list'); } - } else { - console.debug('charlist not ready yet'); - await delay(100); - loadCharListState(); - } +function loadCharListState() { + document.body.classList.toggle('charListGrid', power_user.charListGrid); } function loadMovingUIState() {