Use saved settings for more properties
| @@ -302,8 +302,6 @@ export let context_presets = []; | ||
| 302 | 302 | |
| 303 | 303 | const storage_keys = { |
| 304 | 304 | chat_display: 'TavernAI_chat_display', |
| 305 | - chat_width: 'chat_width', | |
| 306 | - font_scale: 'TavernAI_font_scale', | |
| 307 | 305 | |
| 308 | 306 | main_text_color: 'TavernAI_main_text_color', |
| 309 | 307 | italics_text_color: 'TavernAI_italics_text_color', |
| @@ -313,7 +311,6 @@ const storage_keys = { | ||
| 313 | 311 | chat_tint_color: 'TavernAI_chat_tint_color', |
| 314 | 312 | user_mes_blur_tint_color: 'TavernAI_user_mes_blur_tint_color', |
| 315 | 313 | bot_mes_blur_tint_color: 'TavernAI_bot_mes_blur_tint_color', |
| 316 | - blur_strength: 'TavernAI_blur_strength', | |
| 317 | 314 | shadow_color: 'TavernAI_shadow_color', |
| 318 | 315 | shadow_width: 'TavernAI_shadow_width', |
| 319 | 316 | border_color: 'TavernAI_border_color', |
| @@ -321,17 +318,9 @@ const storage_keys = { | ||
| 321 | 318 | custom_css: 'TavernAI_custom_css', |
| 322 | 319 | |
| 323 | 320 | waifuMode: 'TavernAI_waifuMode', |
| 324 | - movingUI: 'TavernAI_movingUI', | |
| 325 | 321 | |
| 326 | - timer_enabled: 'TimerEnabled', | |
| 327 | - timestamps_enabled: 'TimestampsEnabled', | |
| 328 | 322 | timestamp_model_icon: 'TimestampModelIcon', |
| 329 | - mesIDDisplay_enabled: 'mesIDDisplayEnabled', | |
| 330 | - hideChatAvatars_enabled: 'hideChatAvatarsEnabled', | |
| 331 | 323 | message_token_count_enabled: 'MessageTokenCountEnabled', |
| 332 | - expand_message_actions: 'ExpandMessageActions', | |
| 333 | - enableZenSliders: 'enableZenSliders', | |
| 334 | - enableLabMode: 'enableLabMode', | |
| 335 | 324 | reduced_motion: 'reduced_motion', |
| 336 | 325 | compact_input_area: 'compact_input_area', |
| 337 | 326 | auto_connect_legacy: 'AutoConnectEnabled', |
| @@ -460,15 +449,11 @@ function switchHotswap() { | ||
| 460 | 449 | } |
| 461 | 450 | |
| 462 | 451 | function switchTimer() { |
| 463 | - const value = localStorage.getItem(storage_keys.timer_enabled); | |
| 464 | - power_user.timer_enabled = value === null ? true : value == 'true'; | |
| 465 | 452 | $('body').toggleClass('no-timer', !power_user.timer_enabled); |
| 466 | 453 | $('#messageTimerEnabled').prop('checked', power_user.timer_enabled); |
| 467 | 454 | } |
| 468 | 455 | |
| 469 | 456 | function switchTimestamps() { |
| 470 | - const value = localStorage.getItem(storage_keys.timestamps_enabled); | |
| 471 | - power_user.timestamps_enabled = value === null ? true : value == 'true'; | |
| 472 | 457 | $('body').toggleClass('no-timestamps', !power_user.timestamps_enabled); |
| 473 | 458 | $('#messageTimestampsEnabled').prop('checked', power_user.timestamps_enabled); |
| 474 | 459 | } |
| @@ -488,30 +473,16 @@ function switchTokenCount() { | ||
| 488 | 473 | } |
| 489 | 474 | |
| 490 | 475 | function switchMesIDDisplay() { |
| 491 | - const value = localStorage.getItem(storage_keys.mesIDDisplay_enabled); | |
| 492 | - power_user.mesIDDisplay_enabled = value === null ? true : value == 'true'; | |
| 493 | - /* console.log(` | |
| 494 | - localstorage value:${value}, | |
| 495 | - poweruser before:${before}, | |
| 496 | - poweruser after:${power_user.mesIDDisplay_enabled}`) */ | |
| 497 | 476 | $('body').toggleClass('no-mesIDDisplay', !power_user.mesIDDisplay_enabled); |
| 498 | 477 | $('#mesIDDisplayEnabled').prop('checked', power_user.mesIDDisplay_enabled); |
| 499 | 478 | } |
| 500 | 479 | |
| 501 | 480 | function switchHideChatAvatars() { |
| 502 | - const value = localStorage.getItem(storage_keys.hideChatAvatars_enabled); | |
| 503 | - power_user.hideChatAvatars_enabled = value === null ? false : value == 'true'; | |
| 504 | - /*console.log(` | |
| 505 | - localstorage value:${value}, | |
| 506 | - poweruser after:${power_user.hideChatAvatars_enabled}`) | |
| 507 | - */ | |
| 508 | 481 | $('body').toggleClass('hideChatAvatars', power_user.hideChatAvatars_enabled); |
| 509 | 482 | $('#hideChatAvatarsEnabled').prop('checked', power_user.hideChatAvatars_enabled); |
| 510 | 483 | } |
| 511 | 484 | |
| 512 | 485 | function switchMessageActions() { |
| 513 | - const value = localStorage.getItem(storage_keys.expand_message_actions); | |
| 514 | - power_user.expand_message_actions = value === null ? false : value == 'true'; | |
| 515 | 486 | $('body').toggleClass('expandMessageActions', power_user.expand_message_actions); |
| 516 | 487 | $('#expandMessageActions').prop('checked', power_user.expand_message_actions); |
| 517 | 488 | $('.extraMesButtons, .extraMesButtonsHint').removeAttr('style'); |
| @@ -545,8 +516,6 @@ async function switchLabMode() { | ||
| 545 | 516 | } |
| 546 | 517 | */ |
| 547 | 518 | await delay(100); |
| 548 | - const value = localStorage.getItem(storage_keys.enableLabMode); | |
| 549 | - power_user.enableLabMode = value === null ? false : value == 'true'; | |
| 550 | 519 | $('body').toggleClass('enableLabMode', power_user.enableLabMode); |
| 551 | 520 | $('#enableLabMode').prop('checked', power_user.enableLabMode); |
| 552 | 521 | |
| @@ -593,8 +562,6 @@ async function switchLabMode() { | ||
| 593 | 562 | |
| 594 | 563 | async function switchZenSliders() { |
| 595 | 564 | await delay(100); |
| 596 | - const value = localStorage.getItem(storage_keys.enableZenSliders); | |
| 597 | - power_user.enableZenSliders = value === null ? false : value == 'true'; | |
| 598 | 565 | $('body').toggleClass('enableZenSliders', power_user.enableZenSliders); |
| 599 | 566 | $('#enableZenSliders').prop('checked', power_user.enableZenSliders); |
| 600 | 567 | |
| @@ -1015,8 +982,6 @@ function switchMovingUI() { | ||
| 1015 | 982 | $('.drawer-content.maximized').each(function () { |
| 1016 | 983 | $(this).find('.inline-drawer-maximize').trigger('click'); |
| 1017 | 984 | }); |
| 1018 | - const movingUI = localStorage.getItem(storage_keys.movingUI); | |
| 1019 | - power_user.movingUI = movingUI === null ? false : movingUI == 'true'; | |
| 1020 | 985 | $('body').toggleClass('movingUI', power_user.movingUI); |
| 1021 | 986 | if (power_user.movingUI === true) { |
| 1022 | 987 | initMovingUI(); |
| @@ -1083,8 +1048,6 @@ function applyChatDisplay() { | ||
| 1083 | 1048 | } |
| 1084 | 1049 | |
| 1085 | 1050 | function applyChatWidth(type) { |
| 1086 | - power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50); | |
| 1087 | - | |
| 1088 | 1051 | if (type === 'forced') { |
| 1089 | 1052 | let r = document.documentElement; |
| 1090 | 1053 | r.style.setProperty('--sheldWidth', `${power_user.chat_width}vw`); |
| @@ -1161,12 +1124,9 @@ async function applyCustomCSS() { | ||
| 1161 | 1124 | } |
| 1162 | 1125 | |
| 1163 | 1126 | async function applyBlurStrength() { |
| 1164 | - power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 1); | |
| 1165 | 1127 | document.documentElement.style.setProperty('--blurStrength', power_user.blur_strength); |
| 1166 | 1128 | $('#blur_strength_counter').val(power_user.blur_strength); |
| 1167 | 1129 | $('#blur_strength').val(power_user.blur_strength); |
| 1168 | - | |
| 1169 | - | |
| 1170 | 1130 | } |
| 1171 | 1131 | |
| 1172 | 1132 | async function applyShadowWidth() { |
| @@ -1178,8 +1138,6 @@ async function applyShadowWidth() { | ||
| 1178 | 1138 | } |
| 1179 | 1139 | |
| 1180 | 1140 | async function applyFontScale(type) { |
| 1181 | - | |
| 1182 | - power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1); | |
| 1183 | 1141 | //this is to allow forced setting on page load, theme swap, etc |
| 1184 | 1142 | if (type === 'forced') { |
| 1185 | 1143 | document.documentElement.style.setProperty('--fontScale', power_user.font_scale); |
| @@ -1215,7 +1173,6 @@ async function applyTheme(name) { | ||
| 1215 | 1173 | { |
| 1216 | 1174 | key: 'blur_strength', |
| 1217 | 1175 | action: async () => { |
| 1218 | - localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength); | |
| 1219 | 1176 | await applyBlurStrength(); |
| 1220 | 1177 | }, |
| 1221 | 1178 | }, |
| @@ -1236,7 +1193,6 @@ async function applyTheme(name) { | ||
| 1236 | 1193 | { |
| 1237 | 1194 | key: 'font_scale', |
| 1238 | 1195 | action: async () => { |
| 1239 | - localStorage.setItem(storage_keys.font_scale, power_user.font_scale); | |
| 1240 | 1196 | await applyFontScale('forced'); |
| 1241 | 1197 | }, |
| 1242 | 1198 | }, |
| @@ -1279,22 +1235,19 @@ async function applyTheme(name) { | ||
| 1279 | 1235 | if (!power_user.chat_width) { |
| 1280 | 1236 | power_user.chat_width = 50; |
| 1281 | 1237 | } |
| 1282 | - | |
| 1238 | + saveSettingsDebounced(); | |
| 1283 | - localStorage.setItem(storage_keys.chat_width, String(power_user.chat_width)); | |
| 1284 | 1239 | applyChatWidth('forced'); |
| 1285 | 1240 | }, |
| 1286 | 1241 | }, |
| 1287 | 1242 | { |
| 1288 | 1243 | key: 'timer_enabled', |
| 1289 | 1244 | action: async () => { |
| 1290 | - localStorage.setItem(storage_keys.timer_enabled, Boolean(power_user.timer_enabled)); | |
| 1291 | 1245 | switchTimer(); |
| 1292 | 1246 | }, |
| 1293 | 1247 | }, |
| 1294 | 1248 | { |
| 1295 | 1249 | key: 'timestamps_enabled', |
| 1296 | 1250 | action: async () => { |
| 1297 | - localStorage.setItem(storage_keys.timestamps_enabled, Boolean(power_user.timestamps_enabled)); | |
| 1298 | 1251 | switchTimestamps(); |
| 1299 | 1252 | }, |
| 1300 | 1253 | }, |
| @@ -1315,35 +1268,30 @@ async function applyTheme(name) { | ||
| 1315 | 1268 | { |
| 1316 | 1269 | key: 'mesIDDisplay_enabled', |
| 1317 | 1270 | action: async () => { |
| 1318 | - localStorage.setItem(storage_keys.mesIDDisplay_enabled, Boolean(power_user.mesIDDisplay_enabled)); | |
| 1319 | 1271 | switchMesIDDisplay(); |
| 1320 | 1272 | }, |
| 1321 | 1273 | }, |
| 1322 | 1274 | { |
| 1323 | 1275 | key: 'hideChatAvatars_enabled', |
| 1324 | 1276 | action: async () => { |
| 1325 | - localStorage.setItem(storage_keys.hideChatAvatars_enabled, Boolean(power_user.hideChatAvatars_enabled)); | |
| 1326 | 1277 | switchHideChatAvatars(); |
| 1327 | 1278 | }, |
| 1328 | 1279 | }, |
| 1329 | 1280 | { |
| 1330 | 1281 | key: 'expand_message_actions', |
| 1331 | 1282 | action: async () => { |
| 1332 | - localStorage.setItem(storage_keys.expand_message_actions, Boolean(power_user.expand_message_actions)); | |
| 1333 | 1283 | switchMessageActions(); |
| 1334 | 1284 | }, |
| 1335 | 1285 | }, |
| 1336 | 1286 | { |
| 1337 | 1287 | key: 'enableZenSliders', |
| 1338 | 1288 | action: async () => { |
| 1339 | - localStorage.setItem(storage_keys.enableZenSliders, Boolean(power_user.enableZenSliders)); | |
| 1340 | 1289 | switchMessageActions(); |
| 1341 | 1290 | }, |
| 1342 | 1291 | }, |
| 1343 | 1292 | { |
| 1344 | 1293 | key: 'enableLabMode', |
| 1345 | 1294 | action: async () => { |
| 1346 | - localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode)); | |
| 1347 | 1295 | switchMessageActions(); |
| 1348 | 1296 | }, |
| 1349 | 1297 | }, |
| @@ -1517,14 +1465,6 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1517 | 1465 | } |
| 1518 | 1466 | |
| 1519 | 1467 | // These are still local storage |
| 1520 | - const movingUI = localStorage.getItem(storage_keys.movingUI); | |
| 1521 | - const timer = localStorage.getItem(storage_keys.timer_enabled); | |
| 1522 | - const timestamps = localStorage.getItem(storage_keys.timestamps_enabled); | |
| 1523 | - const mesIDDisplay = localStorage.getItem(storage_keys.mesIDDisplay_enabled); | |
| 1524 | - const hideChatAvatars = localStorage.getItem(storage_keys.hideChatAvatars_enabled); | |
| 1525 | - const expandMessageActions = localStorage.getItem(storage_keys.expand_message_actions); | |
| 1526 | - const enableZenSliders = localStorage.getItem(storage_keys.enableZenSliders); | |
| 1527 | - const enableLabMode = localStorage.getItem(storage_keys.enableLabMode); | |
| 1528 | 1468 | const autoLoadChat = localStorage.getItem(storage_keys.auto_load_chat_legacy); |
| 1529 | 1469 | const autoConnect = localStorage.getItem(storage_keys.auto_connect_legacy); |
| 1530 | 1470 | |
| @@ -1538,18 +1478,6 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1538 | 1478 | localStorage.removeItem(storage_keys.auto_connect_legacy); |
| 1539 | 1479 | } |
| 1540 | 1480 | |
| 1541 | - power_user.movingUI = movingUI === null ? false : movingUI == 'true'; | |
| 1542 | - power_user.timer_enabled = timer === null ? true : timer == 'true'; | |
| 1543 | - power_user.timestamps_enabled = timestamps === null ? true : timestamps == 'true'; | |
| 1544 | - power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == 'true'; | |
| 1545 | - power_user.hideChatAvatars_enabled = hideChatAvatars === null ? true : hideChatAvatars == 'true'; | |
| 1546 | - power_user.expand_message_actions = expandMessageActions === null ? true : expandMessageActions == 'true'; | |
| 1547 | - power_user.enableZenSliders = enableZenSliders === null ? false : enableZenSliders == 'true'; | |
| 1548 | - power_user.enableLabMode = enableLabMode === null ? false : enableLabMode == 'true'; | |
| 1549 | - power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50); | |
| 1550 | - power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1); | |
| 1551 | - power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10); | |
| 1552 | - | |
| 1553 | 1481 | if (power_user.chat_display === '') { |
| 1554 | 1482 | power_user.chat_display = chat_styles.DEFAULT; |
| 1555 | 1483 | } |
| @@ -1558,10 +1486,6 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1558 | 1486 | power_user.waifuMode = false; |
| 1559 | 1487 | } |
| 1560 | 1488 | |
| 1561 | - if (power_user.chat_width === '') { | |
| 1562 | - power_user.chat_width = 50; | |
| 1563 | - } | |
| 1564 | - | |
| 1565 | 1489 | if (power_user.tokenizer === tokenizers.LEGACY) { |
| 1566 | 1490 | power_user.tokenizer = tokenizers.GPT2; |
| 1567 | 1491 | } |
| @@ -3297,7 +3221,6 @@ $(document).ready(() => { | ||
| 3297 | 3221 | |
| 3298 | 3222 | $('#movingUImode').change(function () { |
| 3299 | 3223 | power_user.movingUI = $(this).prop('checked'); |
| 3300 | - localStorage.setItem(storage_keys.movingUI, power_user.movingUI); | |
| 3301 | 3224 | switchMovingUI(); |
| 3302 | 3225 | saveSettingsDebounced(); |
| 3303 | 3226 | }); |
| @@ -3329,8 +3252,8 @@ $(document).ready(() => { | ||
| 3329 | 3252 | $('#chat_width_slider').on('input', function (e, data) { |
| 3330 | 3253 | const applyMode = data?.forced ? 'forced' : 'normal'; |
| 3331 | 3254 | power_user.chat_width = Number(e.target.value); |
| 3332 | - localStorage.setItem(storage_keys.chat_width, power_user.chat_width); | |
| 3333 | 3255 | applyChatWidth(applyMode); |
| 3256 | + saveSettingsDebounced(); | |
| 3334 | 3257 | setHotswapsDebounced(); |
| 3335 | 3258 | }); |
| 3336 | 3259 | |
| @@ -3360,7 +3283,6 @@ $(document).ready(() => { | ||
| 3360 | 3283 | const applyMode = data?.forced ? 'forced' : 'normal'; |
| 3361 | 3284 | power_user.font_scale = Number(e.target.value); |
| 3362 | 3285 | $('#font_scale_counter').val(power_user.font_scale); |
| 3363 | - localStorage.setItem(storage_keys.font_scale, power_user.font_scale); | |
| 3364 | 3286 | await applyFontScale(applyMode); |
| 3365 | 3287 | saveSettingsDebounced(); |
| 3366 | 3288 | }); |
| @@ -3368,7 +3290,6 @@ $(document).ready(() => { | ||
| 3368 | 3290 | $('input[name="blur_strength"]').on('input', async function (e) { |
| 3369 | 3291 | power_user.blur_strength = Number(e.target.value); |
| 3370 | 3292 | $('#blur_strength_counter').val(power_user.blur_strength); |
| 3371 | - localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength); | |
| 3372 | 3293 | await applyBlurStrength(); |
| 3373 | 3294 | saveSettingsDebounced(); |
| 3374 | 3295 | }); |
| @@ -3617,14 +3538,14 @@ $(document).ready(() => { | ||
| 3617 | 3538 | $('#messageTimerEnabled').on('input', function () { |
| 3618 | 3539 | const value = !!$(this).prop('checked'); |
| 3619 | 3540 | power_user.timer_enabled = value; |
| 3620 | - localStorage.setItem(storage_keys.timer_enabled, Boolean(power_user.timer_enabled)); | |
| 3541 | + saveSettingsDebounced(); | |
| 3621 | 3542 | switchTimer(); |
| 3622 | 3543 | }); |
| 3623 | 3544 | |
| 3624 | 3545 | $('#messageTimestampsEnabled').on('input', function () { |
| 3625 | 3546 | const value = !!$(this).prop('checked'); |
| 3626 | 3547 | power_user.timestamps_enabled = value; |
| 3627 | - localStorage.setItem(storage_keys.timestamps_enabled, Boolean(power_user.timestamps_enabled)); | |
| 3548 | + saveSettingsDebounced(); | |
| 3628 | 3549 | switchTimestamps(); |
| 3629 | 3550 | }); |
| 3630 | 3551 | |
| @@ -3632,6 +3553,7 @@ $(document).ready(() => { | ||
| 3632 | 3553 | const value = !!$(this).prop('checked'); |
| 3633 | 3554 | power_user.timestamp_model_icon = value; |
| 3634 | 3555 | localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon)); |
| 3556 | + saveSettingsDebounced(); | |
| 3635 | 3557 | switchIcons(); |
| 3636 | 3558 | }); |
| 3637 | 3559 | |
| @@ -3645,7 +3567,7 @@ $(document).ready(() => { | ||
| 3645 | 3567 | $('#expandMessageActions').on('input', function () { |
| 3646 | 3568 | const value = !!$(this).prop('checked'); |
| 3647 | 3569 | power_user.expand_message_actions = value; |
| 3648 | - localStorage.setItem(storage_keys.expand_message_actions, Boolean(power_user.expand_message_actions)); | |
| 3570 | + saveSettingsDebounced(); | |
| 3649 | 3571 | switchMessageActions(); |
| 3650 | 3572 | }); |
| 3651 | 3573 | |
| @@ -3658,7 +3580,6 @@ $(document).ready(() => { | ||
| 3658 | 3580 | return; |
| 3659 | 3581 | } |
| 3660 | 3582 | power_user.enableZenSliders = value; |
| 3661 | - localStorage.setItem(storage_keys.enableZenSliders, Boolean(power_user.enableZenSliders)); | |
| 3662 | 3583 | saveSettingsDebounced(); |
| 3663 | 3584 | switchZenSliders(); |
| 3664 | 3585 | }); |
| @@ -3673,7 +3594,6 @@ $(document).ready(() => { | ||
| 3673 | 3594 | } |
| 3674 | 3595 | |
| 3675 | 3596 | power_user.enableLabMode = value; |
| 3676 | - localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode)); | |
| 3677 | 3597 | saveSettingsDebounced(); |
| 3678 | 3598 | switchLabMode(); |
| 3679 | 3599 | }); |
| @@ -3681,14 +3601,14 @@ $(document).ready(() => { | ||
| 3681 | 3601 | $('#mesIDDisplayEnabled').on('input', function () { |
| 3682 | 3602 | const value = !!$(this).prop('checked'); |
| 3683 | 3603 | power_user.mesIDDisplay_enabled = value; |
| 3684 | - localStorage.setItem(storage_keys.mesIDDisplay_enabled, Boolean(power_user.mesIDDisplay_enabled)); | |
| 3604 | + saveSettingsDebounced(); | |
| 3685 | 3605 | switchMesIDDisplay(); |
| 3686 | 3606 | }); |
| 3687 | 3607 | |
| 3688 | 3608 | $('#hideChatAvatarsEnabled').on('input', function () { |
| 3689 | 3609 | const value = !!$(this).prop('checked'); |
| 3690 | 3610 | power_user.hideChatAvatars_enabled = value; |
| 3691 | - localStorage.setItem(storage_keys.hideChatAvatars_enabled, Boolean(power_user.hideChatAvatars_enabled)); | |
| 3611 | + saveSettingsDebounced(); | |
| 3692 | 3612 | switchHideChatAvatars(); |
| 3693 | 3613 | }); |
| 3694 | 3614 | |