Merge pull request #2706 from d-ber/saveMoreSettings Save more settings
Signed| @@ -84,6 +84,7 @@ import { | ||
| 84 | 84 | context_presets, |
| 85 | 85 | resetMovableStyles, |
| 86 | 86 | forceCharacterEditorTokenize, |
| 87 | + applyPowerUserSettings, | |
| 87 | 88 | } from './scripts/power-user.js'; |
| 88 | 89 | |
| 89 | 90 | import { |
| @@ -6459,6 +6460,8 @@ export async function getSettings() { | ||
| 6459 | 6460 | // Load power user settings |
| 6460 | 6461 | await loadPowerUserSettings(settings, data); |
| 6461 | 6462 | |
| 6463 | + applyPowerUserSettings(); | |
| 6464 | + | |
| 6462 | 6465 | // Load character tags |
| 6463 | 6466 | loadTagsSettings(settings); |
| 6464 | 6467 | |
| @@ -60,6 +60,7 @@ export { | ||
| 60 | 60 | power_user, |
| 61 | 61 | send_on_enter_options, |
| 62 | 62 | getContextSettings, |
| 63 | + applyPowerUserSettings, | |
| 63 | 64 | }; |
| 64 | 65 | |
| 65 | 66 | export const MAX_CONTEXT_DEFAULT = 8192; |
| @@ -301,43 +302,6 @@ let movingUIPresets = []; | ||
| 301 | 302 | export let context_presets = []; |
| 302 | 303 | |
| 303 | 304 | const storage_keys = { |
| 304 | - fast_ui_mode: 'TavernAI_fast_ui_mode', | |
| 305 | - avatar_style: 'TavernAI_avatar_style', | |
| 306 | - chat_display: 'TavernAI_chat_display', | |
| 307 | - chat_width: 'chat_width', | |
| 308 | - font_scale: 'TavernAI_font_scale', | |
| 309 | - | |
| 310 | - main_text_color: 'TavernAI_main_text_color', | |
| 311 | - italics_text_color: 'TavernAI_italics_text_color', | |
| 312 | - underline_text_color: 'TavernAI_underline_text_color', | |
| 313 | - quote_text_color: 'TavernAI_quote_text_color', | |
| 314 | - blur_tint_color: 'TavernAI_blur_tint_color', | |
| 315 | - chat_tint_color: 'TavernAI_chat_tint_color', | |
| 316 | - user_mes_blur_tint_color: 'TavernAI_user_mes_blur_tint_color', | |
| 317 | - bot_mes_blur_tint_color: 'TavernAI_bot_mes_blur_tint_color', | |
| 318 | - blur_strength: 'TavernAI_blur_strength', | |
| 319 | - shadow_color: 'TavernAI_shadow_color', | |
| 320 | - shadow_width: 'TavernAI_shadow_width', | |
| 321 | - border_color: 'TavernAI_border_color', | |
| 322 | - | |
| 323 | - custom_css: 'TavernAI_custom_css', | |
| 324 | - | |
| 325 | - waifuMode: 'TavernAI_waifuMode', | |
| 326 | - movingUI: 'TavernAI_movingUI', | |
| 327 | - noShadows: 'TavernAI_noShadows', | |
| 328 | - | |
| 329 | - hotswap_enabled: 'HotswapEnabled', | |
| 330 | - timer_enabled: 'TimerEnabled', | |
| 331 | - timestamps_enabled: 'TimestampsEnabled', | |
| 332 | - timestamp_model_icon: 'TimestampModelIcon', | |
| 333 | - mesIDDisplay_enabled: 'mesIDDisplayEnabled', | |
| 334 | - hideChatAvatars_enabled: 'hideChatAvatarsEnabled', | |
| 335 | - message_token_count_enabled: 'MessageTokenCountEnabled', | |
| 336 | - expand_message_actions: 'ExpandMessageActions', | |
| 337 | - enableZenSliders: 'enableZenSliders', | |
| 338 | - enableLabMode: 'enableLabMode', | |
| 339 | - reduced_motion: 'reduced_motion', | |
| 340 | - compact_input_area: 'compact_input_area', | |
| 341 | 305 | auto_connect_legacy: 'AutoConnectEnabled', |
| 342 | 306 | auto_load_chat_legacy: 'AutoLoadChatEnabled', |
| 343 | 307 | |
| @@ -459,73 +423,47 @@ function fixMarkdown(text, forDisplay) { | ||
| 459 | 423 | } |
| 460 | 424 | |
| 461 | 425 | function switchHotswap() { |
| 462 | - const value = localStorage.getItem(storage_keys.hotswap_enabled); | |
| 463 | - power_user.hotswap_enabled = value === null ? true : value == 'true'; | |
| 464 | 426 | $('body').toggleClass('no-hotswap', !power_user.hotswap_enabled); |
| 465 | 427 | $('#hotswapEnabled').prop('checked', power_user.hotswap_enabled); |
| 466 | 428 | } |
| 467 | 429 | |
| 468 | 430 | function switchTimer() { |
| 469 | - const value = localStorage.getItem(storage_keys.timer_enabled); | |
| 470 | - power_user.timer_enabled = value === null ? true : value == 'true'; | |
| 471 | 431 | $('body').toggleClass('no-timer', !power_user.timer_enabled); |
| 472 | 432 | $('#messageTimerEnabled').prop('checked', power_user.timer_enabled); |
| 473 | 433 | } |
| 474 | 434 | |
| 475 | 435 | function switchTimestamps() { |
| 476 | - const value = localStorage.getItem(storage_keys.timestamps_enabled); | |
| 477 | - power_user.timestamps_enabled = value === null ? true : value == 'true'; | |
| 478 | 436 | $('body').toggleClass('no-timestamps', !power_user.timestamps_enabled); |
| 479 | 437 | $('#messageTimestampsEnabled').prop('checked', power_user.timestamps_enabled); |
| 480 | 438 | } |
| 481 | 439 | |
| 482 | 440 | function switchIcons() { |
| 483 | - const value = localStorage.getItem(storage_keys.timestamp_model_icon); | |
| 484 | - power_user.timestamp_model_icon = value === null ? true : value == 'true'; | |
| 485 | 441 | $('body').toggleClass('no-modelIcons', !power_user.timestamp_model_icon); |
| 486 | 442 | $('#messageModelIconEnabled').prop('checked', power_user.timestamp_model_icon); |
| 487 | 443 | } |
| 488 | 444 | |
| 489 | 445 | function switchTokenCount() { |
| 490 | - const value = localStorage.getItem(storage_keys.message_token_count_enabled); | |
| 491 | - power_user.message_token_count_enabled = value === null ? false : value == 'true'; | |
| 492 | 446 | $('body').toggleClass('no-tokenCount', !power_user.message_token_count_enabled); |
| 493 | 447 | $('#messageTokensEnabled').prop('checked', power_user.message_token_count_enabled); |
| 494 | 448 | } |
| 495 | 449 | |
| 496 | 450 | function switchMesIDDisplay() { |
| 497 | - const value = localStorage.getItem(storage_keys.mesIDDisplay_enabled); | |
| 498 | - power_user.mesIDDisplay_enabled = value === null ? true : value == 'true'; | |
| 499 | - /* console.log(` | |
| 500 | - localstorage value:${value}, | |
| 501 | - poweruser before:${before}, | |
| 502 | - poweruser after:${power_user.mesIDDisplay_enabled}`) */ | |
| 503 | 451 | $('body').toggleClass('no-mesIDDisplay', !power_user.mesIDDisplay_enabled); |
| 504 | 452 | $('#mesIDDisplayEnabled').prop('checked', power_user.mesIDDisplay_enabled); |
| 505 | 453 | } |
| 506 | 454 | |
| 507 | 455 | function switchHideChatAvatars() { |
| 508 | - const value = localStorage.getItem(storage_keys.hideChatAvatars_enabled); | |
| 509 | - power_user.hideChatAvatars_enabled = value === null ? false : value == 'true'; | |
| 510 | - /*console.log(` | |
| 511 | - localstorage value:${value}, | |
| 512 | - poweruser after:${power_user.hideChatAvatars_enabled}`) | |
| 513 | - */ | |
| 514 | 456 | $('body').toggleClass('hideChatAvatars', power_user.hideChatAvatars_enabled); |
| 515 | 457 | $('#hideChatAvatarsEnabled').prop('checked', power_user.hideChatAvatars_enabled); |
| 516 | 458 | } |
| 517 | 459 | |
| 518 | 460 | function switchMessageActions() { |
| 519 | - const value = localStorage.getItem(storage_keys.expand_message_actions); | |
| 520 | - power_user.expand_message_actions = value === null ? false : value == 'true'; | |
| 521 | 461 | $('body').toggleClass('expandMessageActions', power_user.expand_message_actions); |
| 522 | 462 | $('#expandMessageActions').prop('checked', power_user.expand_message_actions); |
| 523 | 463 | $('.extraMesButtons, .extraMesButtonsHint').removeAttr('style'); |
| 524 | 464 | } |
| 525 | 465 | |
| 526 | 466 | function switchReducedMotion() { |
| 527 | - const value = localStorage.getItem(storage_keys.reduced_motion); | |
| 528 | - power_user.reduced_motion = value === null ? false : value == 'true'; | |
| 529 | 467 | jQuery.fx.off = power_user.reduced_motion; |
| 530 | 468 | const overrideDuration = power_user.reduced_motion ? 0 : ANIMATION_DURATION_DEFAULT; |
| 531 | 469 | setAnimationDuration(overrideDuration); |
| @@ -534,8 +472,6 @@ function switchReducedMotion() { | ||
| 534 | 472 | } |
| 535 | 473 | |
| 536 | 474 | function switchCompactInputArea() { |
| 537 | - const value = localStorage.getItem(storage_keys.compact_input_area); | |
| 538 | - power_user.compact_input_area = value === null ? true : value == 'true'; | |
| 539 | 475 | $('#send_form').toggleClass('compact', power_user.compact_input_area); |
| 540 | 476 | $('#compact_input_area').prop('checked', power_user.compact_input_area); |
| 541 | 477 | } |
| @@ -551,8 +487,6 @@ async function switchLabMode() { | ||
| 551 | 487 | } |
| 552 | 488 | */ |
| 553 | 489 | await delay(100); |
| 554 | - const value = localStorage.getItem(storage_keys.enableLabMode); | |
| 555 | - power_user.enableLabMode = value === null ? false : value == 'true'; | |
| 556 | 490 | $('body').toggleClass('enableLabMode', power_user.enableLabMode); |
| 557 | 491 | $('#enableLabMode').prop('checked', power_user.enableLabMode); |
| 558 | 492 | |
| @@ -599,8 +533,6 @@ async function switchLabMode() { | ||
| 599 | 533 | |
| 600 | 534 | async function switchZenSliders() { |
| 601 | 535 | await delay(100); |
| 602 | - const value = localStorage.getItem(storage_keys.enableZenSliders); | |
| 603 | - power_user.enableZenSliders = value === null ? false : value == 'true'; | |
| 604 | 536 | $('body').toggleClass('enableZenSliders', power_user.enableZenSliders); |
| 605 | 537 | $('#enableZenSliders').prop('checked', power_user.enableZenSliders); |
| 606 | 538 | |
| @@ -972,8 +904,6 @@ async function CreateZenSliders(elmnt) { | ||
| 972 | 904 | } |
| 973 | 905 | } |
| 974 | 906 | function switchUiMode() { |
| 975 | - const fastUi = localStorage.getItem(storage_keys.fast_ui_mode); | |
| 976 | - power_user.fast_ui_mode = fastUi === null ? true : fastUi == 'true'; | |
| 977 | 907 | $('body').toggleClass('no-blur', power_user.fast_ui_mode); |
| 978 | 908 | $('#fast_ui_mode').prop('checked', power_user.fast_ui_mode); |
| 979 | 909 | if (power_user.fast_ui_mode) { |
| @@ -1023,8 +953,6 @@ function switchMovingUI() { | ||
| 1023 | 953 | $('.drawer-content.maximized').each(function () { |
| 1024 | 954 | $(this).find('.inline-drawer-maximize').trigger('click'); |
| 1025 | 955 | }); |
| 1026 | - const movingUI = localStorage.getItem(storage_keys.movingUI); | |
| 1027 | - power_user.movingUI = movingUI === null ? false : movingUI == 'true'; | |
| 1028 | 956 | $('body').toggleClass('movingUI', power_user.movingUI); |
| 1029 | 957 | if (power_user.movingUI === true) { |
| 1030 | 958 | initMovingUI(); |
| @@ -1040,9 +968,7 @@ function switchMovingUI() { | ||
| 1040 | 968 | } |
| 1041 | 969 | } |
| 1042 | 970 | |
| 1043 | 971 | function noShadowsapplyNoShadows() { |
| 1044 | - const noShadows = localStorage.getItem(storage_keys.noShadows); | |
| 1045 | - power_user.noShadows = noShadows === null ? false : noShadows == 'true'; | |
| 1046 | 972 | $('body').toggleClass('noShadows', power_user.noShadows); |
| 1047 | 973 | $('#noShadowsmode').prop('checked', power_user.noShadows); |
| 1048 | 974 | if (power_user.noShadows) { |
| @@ -1056,12 +982,9 @@ function noShadows() { | ||
| 1056 | 982 | } |
| 1057 | 983 | |
| 1058 | 984 | function applyAvatarStyle() { |
| 1059 | - power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND); | |
| 1060 | 985 | $('body').toggleClass('big-avatars', power_user.avatar_style === avatar_styles.RECTANGULAR); |
| 1061 | 986 | $('body').toggleClass('square-avatars', power_user.avatar_style === avatar_styles.SQUARE); |
| 1062 | 987 | $('#avatar_style').val(power_user.avatar_style).prop('selected', true); |
| 1063 | - //$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true); | |
| 1064 | - | |
| 1065 | 988 | } |
| 1066 | 989 | |
| 1067 | 990 | function applyChatDisplay() { |
| @@ -1096,8 +1019,6 @@ function applyChatDisplay() { | ||
| 1096 | 1019 | } |
| 1097 | 1020 | |
| 1098 | 1021 | function applyChatWidth(type) { |
| 1099 | - power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50); | |
| 1100 | - | |
| 1101 | 1022 | if (type === 'forced') { |
| 1102 | 1023 | let r = document.documentElement; |
| 1103 | 1024 | r.style.setProperty('--sheldWidth', `${power_user.chat_width}vw`); |
| @@ -1159,8 +1080,6 @@ async function applyThemeColor(type) { | ||
| 1159 | 1080 | } |
| 1160 | 1081 | |
| 1161 | 1082 | async function applyCustomCSS() { |
| 1162 | - power_user.custom_css = String(localStorage.getItem(storage_keys.custom_css) ?? ''); | |
| 1163 | - | |
| 1164 | 1083 | $('#customCSS').val(power_user.custom_css); |
| 1165 | 1084 | var styleId = 'custom-style'; |
| 1166 | 1085 | var style = document.getElementById(styleId); |
| @@ -1174,32 +1093,26 @@ async function applyCustomCSS() { | ||
| 1174 | 1093 | } |
| 1175 | 1094 | |
| 1176 | 1095 | async function applyBlurStrength() { |
| 1177 | - power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 1); | |
| 1096 | + document.documentElement.style.setProperty('--blurStrength', String(power_user.blur_strength)); | |
| 1178 | - document.documentElement.style.setProperty('--blurStrength', power_user.blur_strength); | |
| 1179 | 1097 | $('#blur_strength_counter').val(power_user.blur_strength); |
| 1180 | 1098 | $('#blur_strength').val(power_user.blur_strength); |
| 1181 | - | |
| 1182 | - | |
| 1183 | 1099 | } |
| 1184 | 1100 | |
| 1185 | 1101 | async function applyShadowWidth() { |
| 1186 | - power_user.shadow_width = Number(localStorage.getItem(storage_keys.shadow_width) ?? 2); | |
| 1102 | + document.documentElement.style.setProperty('--shadowWidth', String(power_user.shadow_width)); | |
| 1187 | - document.documentElement.style.setProperty('--shadowWidth', power_user.shadow_width); | |
| 1188 | 1103 | $('#shadow_width_counter').val(power_user.shadow_width); |
| 1189 | 1104 | $('#shadow_width').val(power_user.shadow_width); |
| 1190 | 1105 | |
| 1191 | 1106 | } |
| 1192 | 1107 | |
| 1193 | 1108 | async function applyFontScale(type) { |
| 1194 | - | |
| 1195 | - power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1); | |
| 1196 | 1109 | //this is to allow forced setting on page load, theme swap, etc |
| 1197 | 1110 | if (type === 'forced') { |
| 1198 | 1111 | document.documentElement.style.setProperty('--fontScale', String(power_user.font_scale)); |
| 1199 | 1112 | } else { |
| 1200 | 1113 | //this is to prevent the slider from updating page in real time |
| 1201 | 1114 | $('#font_scale').off('mouseup touchend').on('mouseup touchend', () => { |
| 1202 | 1115 | document.documentElement.style.setProperty('--fontScale', String(power_user.font_scale)); |
| 1203 | 1116 | }); |
| 1204 | 1117 | } |
| 1205 | 1118 | |
| @@ -1228,64 +1141,55 @@ async function applyTheme(name) { | ||
| 1228 | 1141 | { |
| 1229 | 1142 | key: 'blur_strength', |
| 1230 | 1143 | action: async () => { |
| 1231 | - localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength); | |
| 1232 | 1144 | await applyBlurStrength(); |
| 1233 | 1145 | }, |
| 1234 | 1146 | }, |
| 1235 | 1147 | { |
| 1236 | 1148 | key: 'custom_css', |
| 1237 | 1149 | action: async () => { |
| 1238 | - localStorage.setItem(storage_keys.custom_css, power_user.custom_css); | |
| 1239 | 1150 | await applyCustomCSS(); |
| 1240 | 1151 | }, |
| 1241 | 1152 | }, |
| 1242 | 1153 | { |
| 1243 | 1154 | key: 'shadow_width', |
| 1244 | 1155 | action: async () => { |
| 1245 | - localStorage.setItem(storage_keys.shadow_width, power_user.shadow_width); | |
| 1246 | 1156 | await applyShadowWidth(); |
| 1247 | 1157 | }, |
| 1248 | 1158 | }, |
| 1249 | 1159 | { |
| 1250 | 1160 | key: 'font_scale', |
| 1251 | 1161 | action: async () => { |
| 1252 | - localStorage.setItem(storage_keys.font_scale, power_user.font_scale); | |
| 1253 | 1162 | await applyFontScale('forced'); |
| 1254 | 1163 | }, |
| 1255 | 1164 | }, |
| 1256 | 1165 | { |
| 1257 | 1166 | key: 'fast_ui_mode', |
| 1258 | 1167 | action: async () => { |
| 1259 | - localStorage.setItem(storage_keys.fast_ui_mode, power_user.fast_ui_mode); | |
| 1260 | 1168 | switchUiMode(); |
| 1261 | 1169 | }, |
| 1262 | 1170 | }, |
| 1263 | 1171 | { |
| 1264 | 1172 | key: 'waifuMode', |
| 1265 | 1173 | action: async () => { |
| 1266 | - localStorage.setItem(storage_keys.waifuMode, power_user.waifuMode); | |
| 1267 | 1174 | switchWaifuMode(); |
| 1268 | 1175 | }, |
| 1269 | 1176 | }, |
| 1270 | 1177 | { |
| 1271 | 1178 | key: 'chat_display', |
| 1272 | 1179 | action: async () => { |
| 1273 | - localStorage.setItem(storage_keys.chat_display, power_user.chat_display); | |
| 1274 | 1180 | applyChatDisplay(); |
| 1275 | 1181 | }, |
| 1276 | 1182 | }, |
| 1277 | 1183 | { |
| 1278 | 1184 | key: 'avatar_style', |
| 1279 | 1185 | action: async () => { |
| 1280 | - localStorage.setItem(storage_keys.avatar_style, power_user.avatar_style); | |
| 1281 | 1186 | applyAvatarStyle(); |
| 1282 | 1187 | }, |
| 1283 | 1188 | }, |
| 1284 | 1189 | { |
| 1285 | 1190 | key: 'noShadows', |
| 1286 | 1191 | action: async () => { |
| 1287 | - localStorage.setItem(storage_keys.noShadows, power_user.noShadows); | |
| 1192 | + applyNoShadows(); | |
| 1288 | - noShadows(); | |
| 1289 | 1193 | }, |
| 1290 | 1194 | }, |
| 1291 | 1195 | { |
| @@ -1295,78 +1199,66 @@ async function applyTheme(name) { | ||
| 1295 | 1199 | if (!power_user.chat_width) { |
| 1296 | 1200 | power_user.chat_width = 50; |
| 1297 | 1201 | } |
| 1298 | - | |
| 1299 | - localStorage.setItem(storage_keys.chat_width, String(power_user.chat_width)); | |
| 1300 | 1202 | applyChatWidth('forced'); |
| 1301 | 1203 | }, |
| 1302 | 1204 | }, |
| 1303 | 1205 | { |
| 1304 | 1206 | key: 'timer_enabled', |
| 1305 | 1207 | action: async () => { |
| 1306 | - localStorage.setItem(storage_keys.timer_enabled, Boolean(power_user.timer_enabled)); | |
| 1307 | 1208 | switchTimer(); |
| 1308 | 1209 | }, |
| 1309 | 1210 | }, |
| 1310 | 1211 | { |
| 1311 | 1212 | key: 'timestamps_enabled', |
| 1312 | 1213 | action: async () => { |
| 1313 | - localStorage.setItem(storage_keys.timestamps_enabled, Boolean(power_user.timestamps_enabled)); | |
| 1314 | 1214 | switchTimestamps(); |
| 1315 | 1215 | }, |
| 1316 | 1216 | }, |
| 1317 | 1217 | { |
| 1318 | 1218 | key: 'timestamp_model_icon', |
| 1319 | 1219 | action: async () => { |
| 1320 | - localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon)); | |
| 1321 | 1220 | switchIcons(); |
| 1322 | 1221 | }, |
| 1323 | 1222 | }, |
| 1324 | 1223 | { |
| 1325 | 1224 | key: 'message_token_count_enabled', |
| 1326 | 1225 | action: async () => { |
| 1327 | - localStorage.setItem(storage_keys.message_token_count_enabled, Boolean(power_user.message_token_count_enabled)); | |
| 1328 | 1226 | switchTokenCount(); |
| 1329 | 1227 | }, |
| 1330 | 1228 | }, |
| 1331 | 1229 | { |
| 1332 | 1230 | key: 'mesIDDisplay_enabled', |
| 1333 | 1231 | action: async () => { |
| 1334 | - localStorage.setItem(storage_keys.mesIDDisplay_enabled, Boolean(power_user.mesIDDisplay_enabled)); | |
| 1335 | 1232 | switchMesIDDisplay(); |
| 1336 | 1233 | }, |
| 1337 | 1234 | }, |
| 1338 | 1235 | { |
| 1339 | 1236 | key: 'hideChatAvatars_enabled', |
| 1340 | 1237 | action: async () => { |
| 1341 | - localStorage.setItem(storage_keys.hideChatAvatars_enabled, Boolean(power_user.hideChatAvatars_enabled)); | |
| 1342 | 1238 | switchHideChatAvatars(); |
| 1343 | 1239 | }, |
| 1344 | 1240 | }, |
| 1345 | 1241 | { |
| 1346 | 1242 | key: 'expand_message_actions', |
| 1347 | 1243 | action: async () => { |
| 1348 | - localStorage.setItem(storage_keys.expand_message_actions, Boolean(power_user.expand_message_actions)); | |
| 1349 | 1244 | switchMessageActions(); |
| 1350 | 1245 | }, |
| 1351 | 1246 | }, |
| 1352 | 1247 | { |
| 1353 | 1248 | key: 'enableZenSliders', |
| 1354 | 1249 | action: async () => { |
| 1355 | - localStorage.setItem(storage_keys.enableZenSliders, Boolean(power_user.enableZenSliders)); | |
| 1356 | 1250 | switchMessageActions(); |
| 1357 | 1251 | }, |
| 1358 | 1252 | }, |
| 1359 | 1253 | { |
| 1360 | 1254 | key: 'enableLabMode', |
| 1361 | 1255 | action: async () => { |
| 1362 | - localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode)); | |
| 1363 | 1256 | switchMessageActions(); |
| 1364 | 1257 | }, |
| 1365 | 1258 | }, |
| 1366 | 1259 | { |
| 1367 | 1260 | key: 'hotswap_enabled', |
| 1368 | 1261 | action: async () => { |
| 1369 | - localStorage.setItem(storage_keys.hotswap_enabled, Boolean(power_user.hotswap_enabled)); | |
| 1370 | 1262 | switchHotswap(); |
| 1371 | 1263 | }, |
| 1372 | 1264 | }, |
| @@ -1387,7 +1279,6 @@ async function applyTheme(name) { | ||
| 1387 | 1279 | { |
| 1388 | 1280 | key: 'reduced_motion', |
| 1389 | 1281 | action: async () => { |
| 1390 | - localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion)); | |
| 1391 | 1282 | $('#reduced_motion').prop('checked', power_user.reduced_motion); |
| 1392 | 1283 | switchReducedMotion(); |
| 1393 | 1284 | }, |
| @@ -1395,7 +1286,6 @@ async function applyTheme(name) { | ||
| 1395 | 1286 | { |
| 1396 | 1287 | key: 'compact_input_area', |
| 1397 | 1288 | action: async () => { |
| 1398 | - localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area)); | |
| 1399 | 1289 | $('#compact_input_area').prop('checked', power_user.compact_input_area); |
| 1400 | 1290 | switchCompactInputArea(); |
| 1401 | 1291 | }, |
| @@ -1450,6 +1340,7 @@ async function showDebugMenu() { | ||
| 1450 | 1340 | callGenericPopup(template, POPUP_TYPE.TEXT, '', { wide: true, large: true, allowVerticalScrolling: true }); |
| 1451 | 1341 | } |
| 1452 | 1342 | |
| 1343 | +function applyPowerUserSettings() { | |
| 1453 | 1344 | switchUiMode(); |
| 1454 | 1345 | applyFontScale('forced'); |
| 1455 | 1346 | applyThemeColor(); |
| @@ -1459,7 +1350,7 @@ applyBlurStrength(); | ||
| 1459 | 1350 | applyShadowWidth(); |
| 1460 | 1351 | applyCustomCSS(); |
| 1461 | 1352 | switchMovingUI(); |
| 1462 | 1353 | noShadows applyNoShadows(); |
| 1463 | 1354 | switchHotswap(); |
| 1464 | 1355 | switchTimer(); |
| 1465 | 1356 | switchTimestamps(); |
| @@ -1468,6 +1359,7 @@ switchMesIDDisplay(); | ||
| 1468 | 1359 | switchHideChatAvatars(); |
| 1469 | 1360 | switchTokenCount(); |
| 1470 | 1361 | switchMessageActions(); |
| 1362 | +} | |
| 1471 | 1363 | |
| 1472 | 1364 | function getExampleMessagesBehavior() { |
| 1473 | 1365 | if (power_user.strip_examples) { |
| @@ -1531,17 +1423,6 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1531 | 1423 | } |
| 1532 | 1424 | |
| 1533 | 1425 | // These are still local storage |
| 1534 | - const fastUi = localStorage.getItem(storage_keys.fast_ui_mode); | |
| 1535 | - const movingUI = localStorage.getItem(storage_keys.movingUI); | |
| 1536 | - const noShadows = localStorage.getItem(storage_keys.noShadows); | |
| 1537 | - const hotswap = localStorage.getItem(storage_keys.hotswap_enabled); | |
| 1538 | - const timer = localStorage.getItem(storage_keys.timer_enabled); | |
| 1539 | - const timestamps = localStorage.getItem(storage_keys.timestamps_enabled); | |
| 1540 | - const mesIDDisplay = localStorage.getItem(storage_keys.mesIDDisplay_enabled); | |
| 1541 | - const hideChatAvatars = localStorage.getItem(storage_keys.hideChatAvatars_enabled); | |
| 1542 | - const expandMessageActions = localStorage.getItem(storage_keys.expand_message_actions); | |
| 1543 | - const enableZenSliders = localStorage.getItem(storage_keys.enableZenSliders); | |
| 1544 | - const enableLabMode = localStorage.getItem(storage_keys.enableLabMode); | |
| 1545 | 1426 | const autoLoadChat = localStorage.getItem(storage_keys.auto_load_chat_legacy); |
| 1546 | 1427 | const autoConnect = localStorage.getItem(storage_keys.auto_connect_legacy); |
| 1547 | 1428 | |
| @@ -1555,23 +1436,6 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1555 | 1436 | localStorage.removeItem(storage_keys.auto_connect_legacy); |
| 1556 | 1437 | } |
| 1557 | 1438 | |
| 1558 | - power_user.fast_ui_mode = fastUi === null ? true : fastUi == 'true'; | |
| 1559 | - power_user.movingUI = movingUI === null ? false : movingUI == 'true'; | |
| 1560 | - power_user.noShadows = noShadows === null ? false : noShadows == 'true'; | |
| 1561 | - power_user.hotswap_enabled = hotswap === null ? true : hotswap == 'true'; | |
| 1562 | - power_user.timer_enabled = timer === null ? true : timer == 'true'; | |
| 1563 | - power_user.timestamps_enabled = timestamps === null ? true : timestamps == 'true'; | |
| 1564 | - power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == 'true'; | |
| 1565 | - power_user.hideChatAvatars_enabled = hideChatAvatars === null ? true : hideChatAvatars == 'true'; | |
| 1566 | - power_user.expand_message_actions = expandMessageActions === null ? true : expandMessageActions == 'true'; | |
| 1567 | - power_user.enableZenSliders = enableZenSliders === null ? false : enableZenSliders == 'true'; | |
| 1568 | - power_user.enableLabMode = enableLabMode === null ? false : enableLabMode == 'true'; | |
| 1569 | - power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND); | |
| 1570 | - //power_user.chat_display = Number(localStorage.getItem(storage_keys.chat_display) ?? chat_styles.DEFAULT); | |
| 1571 | - power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50); | |
| 1572 | - power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1); | |
| 1573 | - power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10); | |
| 1574 | - | |
| 1575 | 1439 | if (power_user.chat_display === '') { |
| 1576 | 1440 | power_user.chat_display = chat_styles.DEFAULT; |
| 1577 | 1441 | } |
| @@ -3298,10 +3162,8 @@ $(document).ready(() => { | ||
| 3298 | 3162 | saveSettingsDebounced(); |
| 3299 | 3163 | }); |
| 3300 | 3164 | |
| 3301 | - // Settings that go to local storage | |
| 3302 | 3165 | $('#fast_ui_mode').change(function () { |
| 3303 | 3166 | power_user.fast_ui_mode = $(this).prop('checked'); |
| 3304 | - localStorage.setItem(storage_keys.fast_ui_mode, power_user.fast_ui_mode); | |
| 3305 | 3167 | switchUiMode(); |
| 3306 | 3168 | saveSettingsDebounced(); |
| 3307 | 3169 | }); |
| @@ -3314,22 +3176,19 @@ $(document).ready(() => { | ||
| 3314 | 3176 | |
| 3315 | 3177 | $('#customCSS').on('input', () => { |
| 3316 | 3178 | power_user.custom_css = String($('#customCSS').val()); |
| 3317 | - localStorage.setItem(storage_keys.custom_css, power_user.custom_css); | |
| 3318 | 3179 | saveSettingsDebounced(); |
| 3319 | 3180 | applyCustomCSS(); |
| 3320 | 3181 | }); |
| 3321 | 3182 | |
| 3322 | 3183 | $('#movingUImode').change(function () { |
| 3323 | 3184 | power_user.movingUI = $(this).prop('checked'); |
| 3324 | - localStorage.setItem(storage_keys.movingUI, power_user.movingUI); | |
| 3325 | 3185 | switchMovingUI(); |
| 3326 | 3186 | saveSettingsDebounced(); |
| 3327 | 3187 | }); |
| 3328 | 3188 | |
| 3329 | 3189 | $('#noShadowsmode').change(function () { |
| 3330 | 3190 | power_user.noShadows = $(this).prop('checked'); |
| 3331 | - localStorage.setItem(storage_keys.noShadows, power_user.noShadows); | |
| 3191 | + applyNoShadows(); | |
| 3332 | - noShadows(); | |
| 3333 | 3192 | saveSettingsDebounced(); |
| 3334 | 3193 | }); |
| 3335 | 3194 | |
| @@ -3338,7 +3197,6 @@ $(document).ready(() => { | ||
| 3338 | 3197 | $('#avatar_style').on('change', function () { |
| 3339 | 3198 | const value = $(this).find(':selected').val(); |
| 3340 | 3199 | power_user.avatar_style = Number(value); |
| 3341 | - localStorage.setItem(storage_keys.avatar_style, power_user.avatar_style); | |
| 3342 | 3200 | applyAvatarStyle(); |
| 3343 | 3201 | saveSettingsDebounced(); |
| 3344 | 3202 | }); |
| @@ -3346,17 +3204,15 @@ $(document).ready(() => { | ||
| 3346 | 3204 | $('#chat_display').on('change', function () { |
| 3347 | 3205 | const value = $(this).find(':selected').val(); |
| 3348 | 3206 | power_user.chat_display = Number(value); |
| 3349 | - localStorage.setItem(storage_keys.chat_display, power_user.chat_display); | |
| 3350 | 3207 | applyChatDisplay(); |
| 3351 | 3208 | saveSettingsDebounced(); |
| 3352 | - | |
| 3353 | 3209 | }); |
| 3354 | 3210 | |
| 3355 | 3211 | $('#chat_width_slider').on('input', function (e, data) { |
| 3356 | 3212 | const applyMode = data?.forced ? 'forced' : 'normal'; |
| 3357 | 3213 | power_user.chat_width = Number(e.target.value); |
| 3358 | - localStorage.setItem(storage_keys.chat_width, power_user.chat_width); | |
| 3359 | 3214 | applyChatWidth(applyMode); |
| 3215 | + saveSettingsDebounced(); | |
| 3360 | 3216 | setHotswapsDebounced(); |
| 3361 | 3217 | }); |
| 3362 | 3218 | |
| @@ -3386,7 +3242,6 @@ $(document).ready(() => { | ||
| 3386 | 3242 | const applyMode = data?.forced ? 'forced' : 'normal'; |
| 3387 | 3243 | power_user.font_scale = Number(e.target.value); |
| 3388 | 3244 | $('#font_scale_counter').val(power_user.font_scale); |
| 3389 | - localStorage.setItem(storage_keys.font_scale, power_user.font_scale); | |
| 3390 | 3245 | await applyFontScale(applyMode); |
| 3391 | 3246 | saveSettingsDebounced(); |
| 3392 | 3247 | }); |
| @@ -3394,7 +3249,6 @@ $(document).ready(() => { | ||
| 3394 | 3249 | $('input[name="blur_strength"]').on('input', async function (e) { |
| 3395 | 3250 | power_user.blur_strength = Number(e.target.value); |
| 3396 | 3251 | $('#blur_strength_counter').val(power_user.blur_strength); |
| 3397 | - localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength); | |
| 3398 | 3252 | await applyBlurStrength(); |
| 3399 | 3253 | saveSettingsDebounced(); |
| 3400 | 3254 | }); |
| @@ -3402,7 +3256,6 @@ $(document).ready(() => { | ||
| 3402 | 3256 | $('input[name="shadow_width"]').on('input', async function (e) { |
| 3403 | 3257 | power_user.shadow_width = Number(e.target.value); |
| 3404 | 3258 | $('#shadow_width_counter').val(power_user.shadow_width); |
| 3405 | - localStorage.setItem(storage_keys.shadow_width, power_user.shadow_width); | |
| 3406 | 3259 | await applyShadowWidth(); |
| 3407 | 3260 | saveSettingsDebounced(); |
| 3408 | 3261 | }); |
| @@ -3643,35 +3496,35 @@ $(document).ready(() => { | ||
| 3643 | 3496 | $('#messageTimerEnabled').on('input', function () { |
| 3644 | 3497 | const value = !!$(this).prop('checked'); |
| 3645 | 3498 | power_user.timer_enabled = value; |
| 3646 | - localStorage.setItem(storage_keys.timer_enabled, Boolean(power_user.timer_enabled)); | |
| 3499 | + saveSettingsDebounced(); | |
| 3647 | 3500 | switchTimer(); |
| 3648 | 3501 | }); |
| 3649 | 3502 | |
| 3650 | 3503 | $('#messageTimestampsEnabled').on('input', function () { |
| 3651 | 3504 | const value = !!$(this).prop('checked'); |
| 3652 | 3505 | power_user.timestamps_enabled = value; |
| 3653 | - localStorage.setItem(storage_keys.timestamps_enabled, Boolean(power_user.timestamps_enabled)); | |
| 3506 | + saveSettingsDebounced(); | |
| 3654 | 3507 | switchTimestamps(); |
| 3655 | 3508 | }); |
| 3656 | 3509 | |
| 3657 | 3510 | $('#messageModelIconEnabled').on('input', function () { |
| 3658 | 3511 | const value = !!$(this).prop('checked'); |
| 3659 | 3512 | power_user.timestamp_model_icon = value; |
| 3660 | - localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon)); | |
| 3513 | + saveSettingsDebounced(); | |
| 3661 | 3514 | switchIcons(); |
| 3662 | 3515 | }); |
| 3663 | 3516 | |
| 3664 | 3517 | $('#messageTokensEnabled').on('input', function () { |
| 3665 | 3518 | const value = !!$(this).prop('checked'); |
| 3666 | 3519 | power_user.message_token_count_enabled = value; |
| 3667 | - localStorage.setItem(storage_keys.message_token_count_enabled, Boolean(power_user.message_token_count_enabled)); | |
| 3520 | + saveSettingsDebounced(); | |
| 3668 | 3521 | switchTokenCount(); |
| 3669 | 3522 | }); |
| 3670 | 3523 | |
| 3671 | 3524 | $('#expandMessageActions').on('input', function () { |
| 3672 | 3525 | const value = !!$(this).prop('checked'); |
| 3673 | 3526 | power_user.expand_message_actions = value; |
| 3674 | - localStorage.setItem(storage_keys.expand_message_actions, Boolean(power_user.expand_message_actions)); | |
| 3527 | + saveSettingsDebounced(); | |
| 3675 | 3528 | switchMessageActions(); |
| 3676 | 3529 | }); |
| 3677 | 3530 | |
| @@ -3684,7 +3537,6 @@ $(document).ready(() => { | ||
| 3684 | 3537 | return; |
| 3685 | 3538 | } |
| 3686 | 3539 | power_user.enableZenSliders = value; |
| 3687 | - localStorage.setItem(storage_keys.enableZenSliders, Boolean(power_user.enableZenSliders)); | |
| 3688 | 3540 | saveSettingsDebounced(); |
| 3689 | 3541 | switchZenSliders(); |
| 3690 | 3542 | }); |
| @@ -3699,7 +3551,6 @@ $(document).ready(() => { | ||
| 3699 | 3551 | } |
| 3700 | 3552 | |
| 3701 | 3553 | power_user.enableLabMode = value; |
| 3702 | - localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode)); | |
| 3703 | 3554 | saveSettingsDebounced(); |
| 3704 | 3555 | switchLabMode(); |
| 3705 | 3556 | }); |
| @@ -3707,22 +3558,22 @@ $(document).ready(() => { | ||
| 3707 | 3558 | $('#mesIDDisplayEnabled').on('input', function () { |
| 3708 | 3559 | const value = !!$(this).prop('checked'); |
| 3709 | 3560 | power_user.mesIDDisplay_enabled = value; |
| 3710 | - localStorage.setItem(storage_keys.mesIDDisplay_enabled, Boolean(power_user.mesIDDisplay_enabled)); | |
| 3561 | + saveSettingsDebounced(); | |
| 3711 | 3562 | switchMesIDDisplay(); |
| 3712 | 3563 | }); |
| 3713 | 3564 | |
| 3714 | 3565 | $('#hideChatAvatarsEnabled').on('input', function () { |
| 3715 | 3566 | const value = !!$(this).prop('checked'); |
| 3716 | 3567 | power_user.hideChatAvatars_enabled = value; |
| 3717 | - localStorage.setItem(storage_keys.hideChatAvatars_enabled, Boolean(power_user.hideChatAvatars_enabled)); | |
| 3568 | + saveSettingsDebounced(); | |
| 3718 | 3569 | switchHideChatAvatars(); |
| 3719 | 3570 | }); |
| 3720 | 3571 | |
| 3721 | 3572 | $('#hotswapEnabled').on('input', function () { |
| 3722 | 3573 | const value = !!$(this).prop('checked'); |
| 3723 | 3574 | power_user.hotswap_enabled = value; |
| 3724 | - localStorage.setItem(storage_keys.hotswap_enabled, Boolean(power_user.hotswap_enabled)); | |
| 3725 | 3575 | switchHotswap(); |
| 3576 | + saveSettingsDebounced(); | |
| 3726 | 3577 | }); |
| 3727 | 3578 | |
| 3728 | 3579 | $('#prefer_character_prompt').on('input', function () { |
| @@ -3935,14 +3786,12 @@ $(document).ready(() => { | ||
| 3935 | 3786 | |
| 3936 | 3787 | $('#reduced_motion').on('input', function () { |
| 3937 | 3788 | power_user.reduced_motion = !!$(this).prop('checked'); |
| 3938 | - localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion)); | |
| 3939 | 3789 | switchReducedMotion(); |
| 3940 | 3790 | saveSettingsDebounced(); |
| 3941 | 3791 | }); |
| 3942 | 3792 | |
| 3943 | 3793 | $('#compact_input_area').on('input', function () { |
| 3944 | 3794 | power_user.compact_input_area = !!$(this).prop('checked'); |
| 3945 | - localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area)); | |
| 3946 | 3795 | switchCompactInputArea(); |
| 3947 | 3796 | saveSettingsDebounced(); |
| 3948 | 3797 | }); |