Remove async in theme toggles load

0b89c8aee9d9ae84c276eba0d0df07e8c2ff7067

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +42 -41Ignore whitespace
public/script.js+1 -0
@@ -6480,6 +6480,7 @@ export async function getSettings() {
64806480 // Load power user settings
64816481 await loadPowerUserSettings(settings, data);
64826482
6483+ // Apply theme toggles from power user settings
64836484 applyPowerUserSettings();
64846485
64856486 // Load character tags
public/scripts/power-user.js+41 -41
@@ -1027,7 +1027,7 @@ function applyChatWidth(type) {
10271027 $('#chat_width_slider_counter').val(power_user.chat_width);
10281028}
10291029
10301030async function applyThemeColor(type) {
10311031 if (type === 'main') {
10321032 document.documentElement.style.setProperty('--SmartThemeBodyColor', power_user.main_text_color);
10331033 const color = power_user.main_text_color.split('(')[1].split(')')[0].split(',');
@@ -1068,7 +1068,7 @@ async function applyThemeColor(type) {
10681068 }
10691069}
10701070
10711071async function applyCustomCSS() {
10721072 $('#customCSS').val(power_user.custom_css);
10731073 var styleId = 'custom-style';
10741074 var style = document.getElementById(styleId);
@@ -1081,20 +1081,20 @@ async function applyCustomCSS() {
10811081 style.innerHTML = power_user.custom_css;
10821082}
10831083
10841084async function applyBlurStrength() {
10851085 document.documentElement.style.setProperty('--blurStrength', String(power_user.blur_strength));
10861086 $('#blur_strength_counter').val(power_user.blur_strength);
10871087 $('#blur_strength').val(power_user.blur_strength);
10881088}
10891089
10901090async function applyShadowWidth() {
10911091 document.documentElement.style.setProperty('--shadowWidth', String(power_user.shadow_width));
10921092 $('#shadow_width_counter').val(power_user.shadow_width);
10931093 $('#shadow_width').val(power_user.shadow_width);
10941094
10951095}
10961096
10971097async function applyFontScale(type) {
10981098 //this is to allow forced setting on page load, theme swap, etc
10991099 if (type === 'forced') {
11001100 document.documentElement.style.setProperty('--fontScale', String(power_user.font_scale));
@@ -1109,7 +1109,7 @@ async function applyFontScale(type) {
11091109 $('#font_scale').val(power_user.font_scale);
11101110}
11111111
11121112async function applyTheme(name) {
11131113 const theme = themes.find(x => x.name == name);
11141114
11151115 if (!theme) {
@@ -1129,61 +1129,61 @@ async function applyTheme(name) {
11291129 { key: 'border_color', selector: '#border-color-picker', type: 'border' },
11301130 {
11311131 key: 'blur_strength',
11321132 action: async () => {
11331133 await applyBlurStrength();
11341134 },
11351135 },
11361136 {
11371137 key: 'custom_css',
11381138 action: async () => {
11391139 await applyCustomCSS();
11401140 },
11411141 },
11421142 {
11431143 key: 'shadow_width',
11441144 action: async () => {
11451145 await applyShadowWidth();
11461146 },
11471147 },
11481148 {
11491149 key: 'font_scale',
11501150 action: async () => {
11511151 await applyFontScale('forced');
11521152 },
11531153 },
11541154 {
11551155 key: 'fast_ui_mode',
11561156 action: async () => {
11571157 switchUiMode();
11581158 },
11591159 },
11601160 {
11611161 key: 'waifuMode',
11621162 action: async () => {
11631163 switchWaifuMode();
11641164 },
11651165 },
11661166 {
11671167 key: 'chat_display',
11681168 action: async () => {
11691169 applyChatDisplay();
11701170 },
11711171 },
11721172 {
11731173 key: 'avatar_style',
11741174 action: async () => {
11751175 applyAvatarStyle();
11761176 },
11771177 },
11781178 {
11791179 key: 'noShadows',
11801180 action: async () => {
11811181 applyNoShadows();
11821182 },
11831183 },
11841184 {
11851185 key: 'chat_width',
11861186 action: async () => {
11871187 // If chat width is not set, set it to 50
11881188 if (!power_user.chat_width) {
11891189 power_user.chat_width = 50;
@@ -1193,88 +1193,88 @@ async function applyTheme(name) {
11931193 },
11941194 {
11951195 key: 'timer_enabled',
11961196 action: async () => {
11971197 switchTimer();
11981198 },
11991199 },
12001200 {
12011201 key: 'timestamps_enabled',
12021202 action: async () => {
12031203 switchTimestamps();
12041204 },
12051205 },
12061206 {
12071207 key: 'timestamp_model_icon',
12081208 action: async () => {
12091209 switchIcons();
12101210 },
12111211 },
12121212 {
12131213 key: 'message_token_count_enabled',
12141214 action: async () => {
12151215 switchTokenCount();
12161216 },
12171217 },
12181218 {
12191219 key: 'mesIDDisplay_enabled',
12201220 action: async () => {
12211221 switchMesIDDisplay();
12221222 },
12231223 },
12241224 {
12251225 key: 'hideChatAvatars_enabled',
12261226 action: async () => {
12271227 switchHideChatAvatars();
12281228 },
12291229 },
12301230 {
12311231 key: 'expand_message_actions',
12321232 action: async () => {
12331233 switchMessageActions();
12341234 },
12351235 },
12361236 {
12371237 key: 'enableZenSliders',
12381238 action: async () => {
12391239 switchMessageActions();
12401240 },
12411241 },
12421242 {
12431243 key: 'enableLabMode',
12441244 action: async () => {
12451245 switchMessageActions();
12461246 },
12471247 },
12481248 {
12491249 key: 'hotswap_enabled',
12501250 action: async () => {
12511251 switchHotswap();
12521252 },
12531253 },
12541254 {
12551255 key: 'bogus_folders',
12561256 action: async () => {
12571257 $('#bogus_folders').prop('checked', power_user.bogus_folders);
12581258 printCharactersDebounced();
12591259 },
12601260 },
12611261 {
12621262 key: 'zoomed_avatar_magnification',
12631263 action: async () => {
12641264 $('#zoomed_avatar_magnification').prop('checked', power_user.zoomed_avatar_magnification);
12651265 printCharactersDebounced();
12661266 },
12671267 },
12681268 {
12691269 key: 'reduced_motion',
12701270 action: async () => {
12711271 $('#reduced_motion').prop('checked', power_user.reduced_motion);
12721272 switchReducedMotion();
12731273 },
12741274 },
12751275 {
12761276 key: 'compact_input_area',
12771277 action: async () => {
12781278 $('#compact_input_area').prop('checked', power_user.compact_input_area);
12791279 switchCompactInputArea();
12801280 },
@@ -1285,8 +1285,8 @@ async function applyTheme(name) {
12851285 if (theme[key] !== undefined) {
12861286 power_user[key] = theme[key];
12871287 if (selector) $(selector).attr('color', power_user[key]);
12881288 if (type) await applyThemeColor(type);
12891289 if (action) await action();
12901290 } else {
12911291 if (selector) { $(selector).attr('color', 'rgba(0,0,0,0)'); }
12921292 console.debug(`Empty theme key: ${key}`);
@@ -1793,7 +1793,7 @@ async function loadContextSettings() {
17931793 .prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
17941794 .trigger('input');
17951795 } else {
17961796 $element[0].innerText = (control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]);
17971797 $element.trigger('input');
17981798 }
17991799 }
@@ -2156,7 +2156,7 @@ async function deleteTheme() {
21562156 power_user.theme = themes[0]?.name;
21572157 saveSettingsDebounced();
21582158 if (power_user.theme) {
21592159 await applyTheme(power_user.theme);
21602160 }
21612161 toastr.success('Theme deleted.');
21622162 }
@@ -3226,21 +3226,21 @@ $(document).ready(() => {
32263226 const applyMode = data?.forced ? 'forced' : 'normal';
32273227 power_user.font_scale = Number(e.target.value);
32283228 $('#font_scale_counter').val(power_user.font_scale);
32293229 await applyFontScale(applyMode);
32303230 saveSettingsDebounced();
32313231 });
32323232
32333233 $('input[name="blur_strength"]').on('input', async function (e) {
32343234 power_user.blur_strength = Number(e.target.value);
32353235 $('#blur_strength_counter').val(power_user.blur_strength);
32363236 await applyBlurStrength();
32373237 saveSettingsDebounced();
32383238 });
32393239
32403240 $('input[name="shadow_width"]').on('input', async function (e) {
32413241 power_user.shadow_width = Number(e.target.value);
32423242 $('#shadow_width_counter').val(power_user.shadow_width);
32433243 await applyShadowWidth();
32443244 saveSettingsDebounced();
32453245 });
32463246