From 262299928470903591b43b123a40003010d2f98e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 10 Aug 2023 12:42:52 +0300 Subject: [PATCH] #911 Fix expressions --- .../scripts/extensions/expressions/index.js | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/public/scripts/extensions/expressions/index.js b/public/scripts/extensions/expressions/index.js index 0c642479b..b40c28c4e 100644 --- a/public/scripts/extensions/expressions/index.js +++ b/public/scripts/extensions/expressions/index.js @@ -515,7 +515,7 @@ async function moduleWorker() { //set checkbox to global var $('#image_type_toggle').prop('checked', extension_settings.expressions.live2d); - if(extension_settings.expressions.live2d == true){ + if (extension_settings.expressions.live2d) { setLive2dState(extension_settings.expressions.live2d); } } @@ -641,11 +641,11 @@ async function live2dcheck() { let live2dObj = spriteCache[spriteFolderName].find(obj => obj.label === 'live2d'); let live2dPath_f = live2dObj ? live2dObj.path : null; - if(live2dPath_f != null){ + if (live2dPath_f != null) { //console.log("live2dPath_f " + live2dPath_f); return true; - } else { - //console.log("live2dPath_f is null"); + } else { + //console.log("live2dPath_f is null"); unloadLiveChar(); return false; } @@ -654,7 +654,7 @@ async function live2dcheck() { } } -function setLive2dState(switch_var){ +function setLive2dState(switch_var) { extension_settings.expressions.live2d = switch_var; // Store setting saveSettingsDebounced(); @@ -662,22 +662,18 @@ function setLive2dState(switch_var){ if (result) { //console.log("Live2d exists!"); - if (extension_settings.expressions.live2d) { - loadLiveChar(); - } else { - unloadLiveChar(); - } - handleImageChange(switch_var); // Change image as needed + if (extension_settings.expressions.live2d) { + loadLiveChar(); + } else { + unloadLiveChar(); + } + handleImageChange(switch_var); // Change image as needed } else { //console.log("Live2d does not exist."); } }); - - - - } function getSpriteFolderName(message) { @@ -867,8 +863,7 @@ async function getExpressionsList() { } async function setExpression(character, expression, force) { - if (extension_settings.expressions.live2d == false) { - + if (!extension_settings.expressions.live2d) { console.debug('entered setExpressions'); await validateImages(character); const img = $('img.expression'); @@ -982,14 +977,14 @@ async function setExpression(character, expression, force) { live2dcheck().then(result => { if (result) { - // Find the element with id="expression-image" and class="expression" - const imgElement = document.querySelector('img#expression-image.expression'); - //console.log("searching"); - if (imgElement) { - //console.log("setting value"); - imgElement.src = getApiUrl() + '/api/live2d/result_feed'; - } - + // Find the element with id="expression-image" and class="expression" + const imgElement = document.querySelector('img#expression-image.expression'); + //console.log("searching"); + if (imgElement) { + //console.log("setting value"); + imgElement.src = getApiUrl() + '/api/live2d/result_feed'; + } + } else { //console.log("The fetch failed!"); } @@ -1254,14 +1249,15 @@ function setExpressionOverrideHtml(forceClear = false) {