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