Use saved settings instead of local storage noShadows, fast_ui_mode, avatar_style and hotswap_enabled are now using settings json instead of local storage.
| @@ -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 { |
| @@ -6450,6 +6451,8 @@ export async function getSettings() { | ||
| 6450 | 6451 | // Load power user settings |
| 6451 | 6452 | await loadPowerUserSettings(settings, data); |
| 6452 | 6453 | |
| 6454 | + applyPowerUserSettings(); | |
| 6455 | + | |
| 6453 | 6456 | // Load character tags |
| 6454 | 6457 | loadTagsSettings(settings); |
| 6455 | 6458 | |
| @@ -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; |
| @@ -300,8 +301,6 @@ let movingUIPresets = []; | ||
| 300 | 301 | export let context_presets = []; |
| 301 | 302 | |
| 302 | 303 | const storage_keys = { |
| 303 | - fast_ui_mode: 'TavernAI_fast_ui_mode', | |
| 304 | - avatar_style: 'TavernAI_avatar_style', | |
| 305 | 304 | chat_display: 'TavernAI_chat_display', |
| 306 | 305 | chat_width: 'chat_width', |
| 307 | 306 | font_scale: 'TavernAI_font_scale', |
| @@ -323,9 +322,7 @@ const storage_keys = { | ||
| 323 | 322 | |
| 324 | 323 | waifuMode: 'TavernAI_waifuMode', |
| 325 | 324 | movingUI: 'TavernAI_movingUI', |
| 326 | - noShadows: 'TavernAI_noShadows', | |
| 327 | 325 | |
| 328 | - hotswap_enabled: 'HotswapEnabled', | |
| 329 | 326 | timer_enabled: 'TimerEnabled', |
| 330 | 327 | timestamps_enabled: 'TimestampsEnabled', |
| 331 | 328 | timestamp_model_icon: 'TimestampModelIcon', |
| @@ -458,8 +455,6 @@ function fixMarkdown(text, forDisplay) { | ||
| 458 | 455 | } |
| 459 | 456 | |
| 460 | 457 | function switchHotswap() { |
| 461 | - const value = localStorage.getItem(storage_keys.hotswap_enabled); | |
| 462 | - power_user.hotswap_enabled = value === null ? true : value == 'true'; | |
| 463 | 458 | $('body').toggleClass('no-hotswap', !power_user.hotswap_enabled); |
| 464 | 459 | $('#hotswapEnabled').prop('checked', power_user.hotswap_enabled); |
| 465 | 460 | } |
| @@ -971,8 +966,6 @@ async function CreateZenSliders(elmnt) { | ||
| 971 | 966 | } |
| 972 | 967 | } |
| 973 | 968 | function switchUiMode() { |
| 974 | - const fastUi = localStorage.getItem(storage_keys.fast_ui_mode); | |
| 975 | - power_user.fast_ui_mode = fastUi === null ? true : fastUi == 'true'; | |
| 976 | 969 | $('body').toggleClass('no-blur', power_user.fast_ui_mode); |
| 977 | 970 | $('#fast_ui_mode').prop('checked', power_user.fast_ui_mode); |
| 978 | 971 | if (power_user.fast_ui_mode) { |
| @@ -1039,9 +1032,7 @@ function switchMovingUI() { | ||
| 1039 | 1032 | } |
| 1040 | 1033 | } |
| 1041 | 1034 | |
| 1042 | 1035 | function noShadowsapplyNoShadows() { |
| 1043 | - const noShadows = localStorage.getItem(storage_keys.noShadows); | |
| 1044 | - power_user.noShadows = noShadows === null ? false : noShadows == 'true'; | |
| 1045 | 1036 | $('body').toggleClass('noShadows', power_user.noShadows); |
| 1046 | 1037 | $('#noShadowsmode').prop('checked', power_user.noShadows); |
| 1047 | 1038 | if (power_user.noShadows) { |
| @@ -1055,12 +1046,9 @@ function noShadows() { | ||
| 1055 | 1046 | } |
| 1056 | 1047 | |
| 1057 | 1048 | function applyAvatarStyle() { |
| 1058 | - power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND); | |
| 1059 | 1049 | $('body').toggleClass('big-avatars', power_user.avatar_style === avatar_styles.RECTANGULAR); |
| 1060 | 1050 | $('body').toggleClass('square-avatars', power_user.avatar_style === avatar_styles.SQUARE); |
| 1061 | 1051 | $('#avatar_style').val(power_user.avatar_style).prop('selected', true); |
| 1062 | - //$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true); | |
| 1063 | - | |
| 1064 | 1052 | } |
| 1065 | 1053 | |
| 1066 | 1054 | function applyChatDisplay() { |
| @@ -1255,7 +1243,6 @@ async function applyTheme(name) { | ||
| 1255 | 1243 | { |
| 1256 | 1244 | key: 'fast_ui_mode', |
| 1257 | 1245 | action: async () => { |
| 1258 | - localStorage.setItem(storage_keys.fast_ui_mode, power_user.fast_ui_mode); | |
| 1259 | 1246 | switchUiMode(); |
| 1260 | 1247 | }, |
| 1261 | 1248 | }, |
| @@ -1276,15 +1263,13 @@ async function applyTheme(name) { | ||
| 1276 | 1263 | { |
| 1277 | 1264 | key: 'avatar_style', |
| 1278 | 1265 | action: async () => { |
| 1279 | - localStorage.setItem(storage_keys.avatar_style, power_user.avatar_style); | |
| 1280 | 1266 | applyAvatarStyle(); |
| 1281 | 1267 | }, |
| 1282 | 1268 | }, |
| 1283 | 1269 | { |
| 1284 | 1270 | key: 'noShadows', |
| 1285 | 1271 | action: async () => { |
| 1286 | - localStorage.setItem(storage_keys.noShadows, power_user.noShadows); | |
| 1272 | + applyNoShadows(); | |
| 1287 | - noShadows(); | |
| 1288 | 1273 | }, |
| 1289 | 1274 | }, |
| 1290 | 1275 | { |
| @@ -1365,7 +1350,6 @@ async function applyTheme(name) { | ||
| 1365 | 1350 | { |
| 1366 | 1351 | key: 'hotswap_enabled', |
| 1367 | 1352 | action: async () => { |
| 1368 | - localStorage.setItem(storage_keys.hotswap_enabled, Boolean(power_user.hotswap_enabled)); | |
| 1369 | 1353 | switchHotswap(); |
| 1370 | 1354 | }, |
| 1371 | 1355 | }, |
| @@ -1449,24 +1433,27 @@ async function showDebugMenu() { | ||
| 1449 | 1433 | callGenericPopup(template, POPUP_TYPE.TEXT, '', { wide: true, large: true, allowVerticalScrolling: true }); |
| 1450 | 1434 | } |
| 1451 | 1435 | |
| 1452 | -switchUiMode(); | |
| 1436 | +function applyPowerUserSettings() { | |
| 1453 | 1437 | applyFontScale switchUiMode('forced'); |
| 1454 | 1438 | applyThemeColor applyFontScale('forced'); |
| 1455 | 1439 | applyChatWidth applyThemeColor('forced'); |
| 1456 | 1440 | applyAvatarStyle applyChatWidth('forced'); |
| 1457 | 1441 | applyBlurStrength applyAvatarStyle(); |
| 1458 | 1442 | applyShadowWidth applyBlurStrength(); |
| 1459 | 1443 | applyCustomCSS applyShadowWidth(); |
| 1460 | 1444 | switchMovingUI applyCustomCSS(); |
| 1461 | 1445 | noShadows switchMovingUI(); |
| 1462 | 1446 | switchHotswap applyNoShadows(); |
| 1463 | 1447 | switchTimer switchHotswap(); |
| 1464 | 1448 | switchTimestamps switchTimer(); |
| 1465 | 1449 | switchIcons switchTimestamps(); |
| 1466 | 1450 | switchMesIDDisplay switchIcons(); |
| 1467 | 1451 | switchHideChatAvatars switchMesIDDisplay(); |
| 1468 | 1452 | switchTokenCount switchHideChatAvatars(); |
| 1469 | 1453 | switchMessageActions switchTokenCount(); |
| 1454 | + switchMessageActions(); | |
| 1455 | +} | |
| 1456 | + | |
| 1470 | 1457 | |
| 1471 | 1458 | function getExampleMessagesBehavior() { |
| 1472 | 1459 | if (power_user.strip_examples) { |
| @@ -1530,10 +1517,7 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1530 | 1517 | } |
| 1531 | 1518 | |
| 1532 | 1519 | // These are still local storage |
| 1533 | - const fastUi = localStorage.getItem(storage_keys.fast_ui_mode); | |
| 1534 | 1520 | const movingUI = localStorage.getItem(storage_keys.movingUI); |
| 1535 | - const noShadows = localStorage.getItem(storage_keys.noShadows); | |
| 1536 | - const hotswap = localStorage.getItem(storage_keys.hotswap_enabled); | |
| 1537 | 1521 | const timer = localStorage.getItem(storage_keys.timer_enabled); |
| 1538 | 1522 | const timestamps = localStorage.getItem(storage_keys.timestamps_enabled); |
| 1539 | 1523 | const mesIDDisplay = localStorage.getItem(storage_keys.mesIDDisplay_enabled); |
| @@ -1554,10 +1538,7 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1554 | 1538 | localStorage.removeItem(storage_keys.auto_connect_legacy); |
| 1555 | 1539 | } |
| 1556 | 1540 | |
| 1557 | - power_user.fast_ui_mode = fastUi === null ? true : fastUi == 'true'; | |
| 1558 | 1541 | power_user.movingUI = movingUI === null ? false : movingUI == 'true'; |
| 1559 | - power_user.noShadows = noShadows === null ? false : noShadows == 'true'; | |
| 1560 | - power_user.hotswap_enabled = hotswap === null ? true : hotswap == 'true'; | |
| 1561 | 1542 | power_user.timer_enabled = timer === null ? true : timer == 'true'; |
| 1562 | 1543 | power_user.timestamps_enabled = timestamps === null ? true : timestamps == 'true'; |
| 1563 | 1544 | power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == 'true'; |
| @@ -1565,8 +1546,6 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1565 | 1546 | power_user.expand_message_actions = expandMessageActions === null ? true : expandMessageActions == 'true'; |
| 1566 | 1547 | power_user.enableZenSliders = enableZenSliders === null ? false : enableZenSliders == 'true'; |
| 1567 | 1548 | power_user.enableLabMode = enableLabMode === null ? false : enableLabMode == 'true'; |
| 1568 | - power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND); | |
| 1569 | - //power_user.chat_display = Number(localStorage.getItem(storage_keys.chat_display) ?? chat_styles.DEFAULT); | |
| 1570 | 1549 | power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50); |
| 1571 | 1550 | power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1); |
| 1572 | 1551 | power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10); |
| @@ -3299,7 +3278,6 @@ $(document).ready(() => { | ||
| 3299 | 3278 | // Settings that go to local storage |
| 3300 | 3279 | $('#fast_ui_mode').change(function () { |
| 3301 | 3280 | power_user.fast_ui_mode = $(this).prop('checked'); |
| 3302 | - localStorage.setItem(storage_keys.fast_ui_mode, power_user.fast_ui_mode); | |
| 3303 | 3281 | switchUiMode(); |
| 3304 | 3282 | saveSettingsDebounced(); |
| 3305 | 3283 | }); |
| @@ -3326,8 +3304,7 @@ $(document).ready(() => { | ||
| 3326 | 3304 | |
| 3327 | 3305 | $('#noShadowsmode').change(function () { |
| 3328 | 3306 | power_user.noShadows = $(this).prop('checked'); |
| 3329 | - localStorage.setItem(storage_keys.noShadows, power_user.noShadows); | |
| 3307 | + applyNoShadows(); | |
| 3330 | - noShadows(); | |
| 3331 | 3308 | saveSettingsDebounced(); |
| 3332 | 3309 | }); |
| 3333 | 3310 | |
| @@ -3336,7 +3313,6 @@ $(document).ready(() => { | ||
| 3336 | 3313 | $('#avatar_style').on('change', function () { |
| 3337 | 3314 | const value = $(this).find(':selected').val(); |
| 3338 | 3315 | power_user.avatar_style = Number(value); |
| 3339 | - localStorage.setItem(storage_keys.avatar_style, power_user.avatar_style); | |
| 3340 | 3316 | applyAvatarStyle(); |
| 3341 | 3317 | saveSettingsDebounced(); |
| 3342 | 3318 | }); |
| @@ -3719,8 +3695,8 @@ $(document).ready(() => { | ||
| 3719 | 3695 | $('#hotswapEnabled').on('input', function () { |
| 3720 | 3696 | const value = !!$(this).prop('checked'); |
| 3721 | 3697 | power_user.hotswap_enabled = value; |
| 3722 | - localStorage.setItem(storage_keys.hotswap_enabled, Boolean(power_user.hotswap_enabled)); | |
| 3723 | 3698 | switchHotswap(); |
| 3699 | + saveSettingsDebounced(); | |
| 3724 | 3700 | }); |
| 3725 | 3701 | |
| 3726 | 3702 | $('#prefer_character_prompt').on('input', function () { |