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