Remove async in theme toggles load

0b89c8aee9d9ae84c276eba0d0df07e8c2ff7067

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

2 files changed, +42 -41Showing whitespace changes
public/script.js+1 -0
@@ -6480,6 +6480,7 @@ export async function getSettings() {
6480 // Load power user settings6480 // Load power user settings
6481 await loadPowerUserSettings(settings, data);6481 await loadPowerUserSettings(settings, data);
64826482
6483 // Apply theme toggles from power user settings
6483 applyPowerUserSettings();6484 applyPowerUserSettings();
64846485
6485 // Load character tags6486 // Load character tags
public/scripts/power-user.js+41 -41
@@ -1027,7 +1027,7 @@ function applyChatWidth(type) {
1027 $('#chat_width_slider_counter').val(power_user.chat_width);1027 $('#chat_width_slider_counter').val(power_user.chat_width);
1028}1028}
10291029
1030async function applyThemeColor(type) {1030function applyThemeColor(type) {
1031 if (type === 'main') {1031 if (type === 'main') {
1032 document.documentElement.style.setProperty('--SmartThemeBodyColor', power_user.main_text_color);1032 document.documentElement.style.setProperty('--SmartThemeBodyColor', power_user.main_text_color);
1033 const color = power_user.main_text_color.split('(')[1].split(')')[0].split(',');1033 const color = power_user.main_text_color.split('(')[1].split(')')[0].split(',');
@@ -1068,7 +1068,7 @@ async function applyThemeColor(type) {
1068 }1068 }
1069}1069}
10701070
1071async function applyCustomCSS() {1071function applyCustomCSS() {
1072 $('#customCSS').val(power_user.custom_css);1072 $('#customCSS').val(power_user.custom_css);
1073 var styleId = 'custom-style';1073 var styleId = 'custom-style';
1074 var style = document.getElementById(styleId);1074 var style = document.getElementById(styleId);
@@ -1081,20 +1081,20 @@ async function applyCustomCSS() {
1081 style.innerHTML = power_user.custom_css;1081 style.innerHTML = power_user.custom_css;
1082}1082}
10831083
1084async function applyBlurStrength() {1084function applyBlurStrength() {
1085 document.documentElement.style.setProperty('--blurStrength', String(power_user.blur_strength));1085 document.documentElement.style.setProperty('--blurStrength', String(power_user.blur_strength));
1086 $('#blur_strength_counter').val(power_user.blur_strength);1086 $('#blur_strength_counter').val(power_user.blur_strength);
1087 $('#blur_strength').val(power_user.blur_strength);1087 $('#blur_strength').val(power_user.blur_strength);
1088}1088}
10891089
1090async function applyShadowWidth() {1090function applyShadowWidth() {
1091 document.documentElement.style.setProperty('--shadowWidth', String(power_user.shadow_width));1091 document.documentElement.style.setProperty('--shadowWidth', String(power_user.shadow_width));
1092 $('#shadow_width_counter').val(power_user.shadow_width);1092 $('#shadow_width_counter').val(power_user.shadow_width);
1093 $('#shadow_width').val(power_user.shadow_width);1093 $('#shadow_width').val(power_user.shadow_width);
10941094
1095}1095}
10961096
1097async function applyFontScale(type) {1097function applyFontScale(type) {
1098 //this is to allow forced setting on page load, theme swap, etc1098 //this is to allow forced setting on page load, theme swap, etc
1099 if (type === 'forced') {1099 if (type === 'forced') {
1100 document.documentElement.style.setProperty('--fontScale', String(power_user.font_scale));1100 document.documentElement.style.setProperty('--fontScale', String(power_user.font_scale));
@@ -1109,7 +1109,7 @@ async function applyFontScale(type) {
1109 $('#font_scale').val(power_user.font_scale);1109 $('#font_scale').val(power_user.font_scale);
1110}1110}
11111111
1112async function applyTheme(name) {1112function applyTheme(name) {
1113 const theme = themes.find(x => x.name == name);1113 const theme = themes.find(x => x.name == name);
11141114
1115 if (!theme) {1115 if (!theme) {
@@ -1129,61 +1129,61 @@ async function applyTheme(name) {
1129 { key: 'border_color', selector: '#border-color-picker', type: 'border' },1129 { key: 'border_color', selector: '#border-color-picker', type: 'border' },
1130 {1130 {
1131 key: 'blur_strength',1131 key: 'blur_strength',
1132 action: async () => {1132 action: () => {
1133 await applyBlurStrength();1133 applyBlurStrength();
1134 },1134 },
1135 },1135 },
1136 {1136 {
1137 key: 'custom_css',1137 key: 'custom_css',
1138 action: async () => {1138 action: () => {
1139 await applyCustomCSS();1139 applyCustomCSS();
1140 },1140 },
1141 },1141 },
1142 {1142 {
1143 key: 'shadow_width',1143 key: 'shadow_width',
1144 action: async () => {1144 action: () => {
1145 await applyShadowWidth();1145 applyShadowWidth();
1146 },1146 },
1147 },1147 },
1148 {1148 {
1149 key: 'font_scale',1149 key: 'font_scale',
1150 action: async () => {1150 action: () => {
1151 await applyFontScale('forced');1151 applyFontScale('forced');
1152 },1152 },
1153 },1153 },
1154 {1154 {
1155 key: 'fast_ui_mode',1155 key: 'fast_ui_mode',
1156 action: async () => {1156 action: () => {
1157 switchUiMode();1157 switchUiMode();
1158 },1158 },
1159 },1159 },
1160 {1160 {
1161 key: 'waifuMode',1161 key: 'waifuMode',
1162 action: async () => {1162 action: () => {
1163 switchWaifuMode();1163 switchWaifuMode();
1164 },1164 },
1165 },1165 },
1166 {1166 {
1167 key: 'chat_display',1167 key: 'chat_display',
1168 action: async () => {1168 action: () => {
1169 applyChatDisplay();1169 applyChatDisplay();
1170 },1170 },
1171 },1171 },
1172 {1172 {
1173 key: 'avatar_style',1173 key: 'avatar_style',
1174 action: async () => {1174 action: () => {
1175 applyAvatarStyle();1175 applyAvatarStyle();
1176 },1176 },
1177 },1177 },
1178 {1178 {
1179 key: 'noShadows',1179 key: 'noShadows',
1180 action: async () => {1180 action: () => {
1181 applyNoShadows();1181 applyNoShadows();
1182 },1182 },
1183 },1183 },
1184 {1184 {
1185 key: 'chat_width',1185 key: 'chat_width',
1186 action: async () => {1186 action: () => {
1187 // If chat width is not set, set it to 501187 // If chat width is not set, set it to 50
1188 if (!power_user.chat_width) {1188 if (!power_user.chat_width) {
1189 power_user.chat_width = 50;1189 power_user.chat_width = 50;
@@ -1193,88 +1193,88 @@ async function applyTheme(name) {
1193 },1193 },
1194 {1194 {
1195 key: 'timer_enabled',1195 key: 'timer_enabled',
1196 action: async () => {1196 action: () => {
1197 switchTimer();1197 switchTimer();
1198 },1198 },
1199 },1199 },
1200 {1200 {
1201 key: 'timestamps_enabled',1201 key: 'timestamps_enabled',
1202 action: async () => {1202 action: () => {
1203 switchTimestamps();1203 switchTimestamps();
1204 },1204 },
1205 },1205 },
1206 {1206 {
1207 key: 'timestamp_model_icon',1207 key: 'timestamp_model_icon',
1208 action: async () => {1208 action: () => {
1209 switchIcons();1209 switchIcons();
1210 },1210 },
1211 },1211 },
1212 {1212 {
1213 key: 'message_token_count_enabled',1213 key: 'message_token_count_enabled',
1214 action: async () => {1214 action: () => {
1215 switchTokenCount();1215 switchTokenCount();
1216 },1216 },
1217 },1217 },
1218 {1218 {
1219 key: 'mesIDDisplay_enabled',1219 key: 'mesIDDisplay_enabled',
1220 action: async () => {1220 action: () => {
1221 switchMesIDDisplay();1221 switchMesIDDisplay();
1222 },1222 },
1223 },1223 },
1224 {1224 {
1225 key: 'hideChatAvatars_enabled',1225 key: 'hideChatAvatars_enabled',
1226 action: async () => {1226 action: () => {
1227 switchHideChatAvatars();1227 switchHideChatAvatars();
1228 },1228 },
1229 },1229 },
1230 {1230 {
1231 key: 'expand_message_actions',1231 key: 'expand_message_actions',
1232 action: async () => {1232 action: () => {
1233 switchMessageActions();1233 switchMessageActions();
1234 },1234 },
1235 },1235 },
1236 {1236 {
1237 key: 'enableZenSliders',1237 key: 'enableZenSliders',
1238 action: async () => {1238 action: () => {
1239 switchMessageActions();1239 switchMessageActions();
1240 },1240 },
1241 },1241 },
1242 {1242 {
1243 key: 'enableLabMode',1243 key: 'enableLabMode',
1244 action: async () => {1244 action: () => {
1245 switchMessageActions();1245 switchMessageActions();
1246 },1246 },
1247 },1247 },
1248 {1248 {
1249 key: 'hotswap_enabled',1249 key: 'hotswap_enabled',
1250 action: async () => {1250 action: () => {
1251 switchHotswap();1251 switchHotswap();
1252 },1252 },
1253 },1253 },
1254 {1254 {
1255 key: 'bogus_folders',1255 key: 'bogus_folders',
1256 action: async () => {1256 action: () => {
1257 $('#bogus_folders').prop('checked', power_user.bogus_folders);1257 $('#bogus_folders').prop('checked', power_user.bogus_folders);
1258 printCharactersDebounced();1258 printCharactersDebounced();
1259 },1259 },
1260 },1260 },
1261 {1261 {
1262 key: 'zoomed_avatar_magnification',1262 key: 'zoomed_avatar_magnification',
1263 action: async () => {1263 action: () => {
1264 $('#zoomed_avatar_magnification').prop('checked', power_user.zoomed_avatar_magnification);1264 $('#zoomed_avatar_magnification').prop('checked', power_user.zoomed_avatar_magnification);
1265 printCharactersDebounced();1265 printCharactersDebounced();
1266 },1266 },
1267 },1267 },
1268 {1268 {
1269 key: 'reduced_motion',1269 key: 'reduced_motion',
1270 action: async () => {1270 action: () => {
1271 $('#reduced_motion').prop('checked', power_user.reduced_motion);1271 $('#reduced_motion').prop('checked', power_user.reduced_motion);
1272 switchReducedMotion();1272 switchReducedMotion();
1273 },1273 },
1274 },1274 },
1275 {1275 {
1276 key: 'compact_input_area',1276 key: 'compact_input_area',
1277 action: async () => {1277 action: () => {
1278 $('#compact_input_area').prop('checked', power_user.compact_input_area);1278 $('#compact_input_area').prop('checked', power_user.compact_input_area);
1279 switchCompactInputArea();1279 switchCompactInputArea();
1280 },1280 },
@@ -1285,8 +1285,8 @@ async function applyTheme(name) {
1285 if (theme[key] !== undefined) {1285 if (theme[key] !== undefined) {
1286 power_user[key] = theme[key];1286 power_user[key] = theme[key];
1287 if (selector) $(selector).attr('color', power_user[key]);1287 if (selector) $(selector).attr('color', power_user[key]);
1288 if (type) await applyThemeColor(type);1288 if (type) applyThemeColor(type);
1289 if (action) await action();1289 if (action) action();
1290 } else {1290 } else {
1291 if (selector) { $(selector).attr('color', 'rgba(0,0,0,0)'); }1291 if (selector) { $(selector).attr('color', 'rgba(0,0,0,0)'); }
1292 console.debug(`Empty theme key: ${key}`);1292 console.debug(`Empty theme key: ${key}`);
@@ -1793,7 +1793,7 @@ async function loadContextSettings() {
1793 .prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])1793 .prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
1794 .trigger('input');1794 .trigger('input');
1795 } else {1795 } else {
1796 $element[0].innerText = (control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])1796 $element[0].innerText = (control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]);
1797 $element.trigger('input');1797 $element.trigger('input');
1798 }1798 }
1799 }1799 }
@@ -2156,7 +2156,7 @@ async function deleteTheme() {
2156 power_user.theme = themes[0]?.name;2156 power_user.theme = themes[0]?.name;
2157 saveSettingsDebounced();2157 saveSettingsDebounced();
2158 if (power_user.theme) {2158 if (power_user.theme) {
2159 await applyTheme(power_user.theme);2159 applyTheme(power_user.theme);
2160 }2160 }
2161 toastr.success('Theme deleted.');2161 toastr.success('Theme deleted.');
2162 }2162 }
@@ -3226,21 +3226,21 @@ $(document).ready(() => {
3226 const applyMode = data?.forced ? 'forced' : 'normal';3226 const applyMode = data?.forced ? 'forced' : 'normal';
3227 power_user.font_scale = Number(e.target.value);3227 power_user.font_scale = Number(e.target.value);
3228 $('#font_scale_counter').val(power_user.font_scale);3228 $('#font_scale_counter').val(power_user.font_scale);
3229 await applyFontScale(applyMode);3229 applyFontScale(applyMode);
3230 saveSettingsDebounced();3230 saveSettingsDebounced();
3231 });3231 });
32323232
3233 $('input[name="blur_strength"]').on('input', async function (e) {3233 $('input[name="blur_strength"]').on('input', async function (e) {
3234 power_user.blur_strength = Number(e.target.value);3234 power_user.blur_strength = Number(e.target.value);
3235 $('#blur_strength_counter').val(power_user.blur_strength);3235 $('#blur_strength_counter').val(power_user.blur_strength);
3236 await applyBlurStrength();3236 applyBlurStrength();
3237 saveSettingsDebounced();3237 saveSettingsDebounced();
3238 });3238 });
32393239
3240 $('input[name="shadow_width"]').on('input', async function (e) {3240 $('input[name="shadow_width"]').on('input', async function (e) {
3241 power_user.shadow_width = Number(e.target.value);3241 power_user.shadow_width = Number(e.target.value);
3242 $('#shadow_width_counter').val(power_user.shadow_width);3242 $('#shadow_width_counter').val(power_user.shadow_width);
3243 await applyShadowWidth();3243 applyShadowWidth();
3244 saveSettingsDebounced();3244 saveSettingsDebounced();
3245 });3245 });
32463246