Use saved settings for more properties
| @@ -301,8 +301,6 @@ let movingUIPresets = []; | ||
| 301 | 301 | export let context_presets = []; |
| 302 | 302 | |
| 303 | 303 | const storage_keys = { |
| 304 | - chat_display: 'TavernAI_chat_display', | |
| 305 | - | |
| 306 | 304 | main_text_color: 'TavernAI_main_text_color', |
| 307 | 305 | italics_text_color: 'TavernAI_italics_text_color', |
| 308 | 306 | underline_text_color: 'TavernAI_underline_text_color', |
| @@ -317,12 +315,6 @@ const storage_keys = { | ||
| 317 | 315 | |
| 318 | 316 | custom_css: 'TavernAI_custom_css', |
| 319 | 317 | |
| 320 | - waifuMode: 'TavernAI_waifuMode', | |
| 321 | - | |
| 322 | - timestamp_model_icon: 'TimestampModelIcon', | |
| 323 | - message_token_count_enabled: 'MessageTokenCountEnabled', | |
| 324 | - reduced_motion: 'reduced_motion', | |
| 325 | - compact_input_area: 'compact_input_area', | |
| 326 | 318 | auto_connect_legacy: 'AutoConnectEnabled', |
| 327 | 319 | auto_load_chat_legacy: 'AutoLoadChatEnabled', |
| 328 | 320 | |
| @@ -459,15 +451,11 @@ function switchTimestamps() { | ||
| 459 | 451 | } |
| 460 | 452 | |
| 461 | 453 | function switchIcons() { |
| 462 | - const value = localStorage.getItem(storage_keys.timestamp_model_icon); | |
| 463 | - power_user.timestamp_model_icon = value === null ? true : value == 'true'; | |
| 464 | 454 | $('body').toggleClass('no-modelIcons', !power_user.timestamp_model_icon); |
| 465 | 455 | $('#messageModelIconEnabled').prop('checked', power_user.timestamp_model_icon); |
| 466 | 456 | } |
| 467 | 457 | |
| 468 | 458 | function switchTokenCount() { |
| 469 | - const value = localStorage.getItem(storage_keys.message_token_count_enabled); | |
| 470 | - power_user.message_token_count_enabled = value === null ? false : value == 'true'; | |
| 471 | 459 | $('body').toggleClass('no-tokenCount', !power_user.message_token_count_enabled); |
| 472 | 460 | $('#messageTokensEnabled').prop('checked', power_user.message_token_count_enabled); |
| 473 | 461 | } |
| @@ -489,8 +477,6 @@ function switchMessageActions() { | ||
| 489 | 477 | } |
| 490 | 478 | |
| 491 | 479 | function switchReducedMotion() { |
| 492 | - const value = localStorage.getItem(storage_keys.reduced_motion); | |
| 493 | - power_user.reduced_motion = value === null ? false : value == 'true'; | |
| 494 | 480 | jQuery.fx.off = power_user.reduced_motion; |
| 495 | 481 | const overrideDuration = power_user.reduced_motion ? 0 : ANIMATION_DURATION_DEFAULT; |
| 496 | 482 | setAnimationDuration(overrideDuration); |
| @@ -499,8 +485,6 @@ function switchReducedMotion() { | ||
| 499 | 485 | } |
| 500 | 486 | |
| 501 | 487 | function switchCompactInputArea() { |
| 502 | - const value = localStorage.getItem(storage_keys.compact_input_area); | |
| 503 | - power_user.compact_input_area = value === null ? true : value == 'true'; | |
| 504 | 488 | $('#send_form').toggleClass('compact', power_user.compact_input_area); |
| 505 | 489 | $('#compact_input_area').prop('checked', power_user.compact_input_area); |
| 506 | 490 | } |
| @@ -1205,14 +1189,12 @@ async function applyTheme(name) { | ||
| 1205 | 1189 | { |
| 1206 | 1190 | key: 'waifuMode', |
| 1207 | 1191 | action: async () => { |
| 1208 | - localStorage.setItem(storage_keys.waifuMode, power_user.waifuMode); | |
| 1209 | 1192 | switchWaifuMode(); |
| 1210 | 1193 | }, |
| 1211 | 1194 | }, |
| 1212 | 1195 | { |
| 1213 | 1196 | key: 'chat_display', |
| 1214 | 1197 | action: async () => { |
| 1215 | - localStorage.setItem(storage_keys.chat_display, power_user.chat_display); | |
| 1216 | 1198 | applyChatDisplay(); |
| 1217 | 1199 | }, |
| 1218 | 1200 | }, |
| @@ -1235,7 +1217,6 @@ async function applyTheme(name) { | ||
| 1235 | 1217 | if (!power_user.chat_width) { |
| 1236 | 1218 | power_user.chat_width = 50; |
| 1237 | 1219 | } |
| 1238 | - saveSettingsDebounced(); | |
| 1239 | 1220 | applyChatWidth('forced'); |
| 1240 | 1221 | }, |
| 1241 | 1222 | }, |
| @@ -1254,14 +1235,12 @@ async function applyTheme(name) { | ||
| 1254 | 1235 | { |
| 1255 | 1236 | key: 'timestamp_model_icon', |
| 1256 | 1237 | action: async () => { |
| 1257 | - localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon)); | |
| 1258 | 1238 | switchIcons(); |
| 1259 | 1239 | }, |
| 1260 | 1240 | }, |
| 1261 | 1241 | { |
| 1262 | 1242 | key: 'message_token_count_enabled', |
| 1263 | 1243 | action: async () => { |
| 1264 | - localStorage.setItem(storage_keys.message_token_count_enabled, Boolean(power_user.message_token_count_enabled)); | |
| 1265 | 1244 | switchTokenCount(); |
| 1266 | 1245 | }, |
| 1267 | 1246 | }, |
| @@ -1318,7 +1297,6 @@ async function applyTheme(name) { | ||
| 1318 | 1297 | { |
| 1319 | 1298 | key: 'reduced_motion', |
| 1320 | 1299 | action: async () => { |
| 1321 | - localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion)); | |
| 1322 | 1300 | $('#reduced_motion').prop('checked', power_user.reduced_motion); |
| 1323 | 1301 | switchReducedMotion(); |
| 1324 | 1302 | }, |
| @@ -1326,7 +1304,6 @@ async function applyTheme(name) { | ||
| 1326 | 1304 | { |
| 1327 | 1305 | key: 'compact_input_area', |
| 1328 | 1306 | action: async () => { |
| 1329 | - localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area)); | |
| 1330 | 1307 | $('#compact_input_area').prop('checked', power_user.compact_input_area); |
| 1331 | 1308 | switchCompactInputArea(); |
| 1332 | 1309 | }, |
| @@ -1486,6 +1463,10 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1486 | 1463 | power_user.waifuMode = false; |
| 1487 | 1464 | } |
| 1488 | 1465 | |
| 1466 | + if (power_user.chat_width === '') { | |
| 1467 | + power_user.chat_width = 50; | |
| 1468 | + } | |
| 1469 | + | |
| 1489 | 1470 | if (power_user.tokenizer === tokenizers.LEGACY) { |
| 1490 | 1471 | power_user.tokenizer = tokenizers.GPT2; |
| 1491 | 1472 | } |
| @@ -3243,10 +3224,8 @@ $(document).ready(() => { | ||
| 3243 | 3224 | $('#chat_display').on('change', function () { |
| 3244 | 3225 | const value = $(this).find(':selected').val(); |
| 3245 | 3226 | power_user.chat_display = Number(value); |
| 3246 | - localStorage.setItem(storage_keys.chat_display, power_user.chat_display); | |
| 3247 | 3227 | applyChatDisplay(); |
| 3248 | 3228 | saveSettingsDebounced(); |
| 3249 | - | |
| 3250 | 3229 | }); |
| 3251 | 3230 | |
| 3252 | 3231 | $('#chat_width_slider').on('input', function (e, data) { |
| @@ -3552,7 +3531,6 @@ $(document).ready(() => { | ||
| 3552 | 3531 | $('#messageModelIconEnabled').on('input', function () { |
| 3553 | 3532 | const value = !!$(this).prop('checked'); |
| 3554 | 3533 | power_user.timestamp_model_icon = value; |
| 3555 | - localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon)); | |
| 3556 | 3534 | saveSettingsDebounced(); |
| 3557 | 3535 | switchIcons(); |
| 3558 | 3536 | }); |
| @@ -3560,7 +3538,7 @@ $(document).ready(() => { | ||
| 3560 | 3538 | $('#messageTokensEnabled').on('input', function () { |
| 3561 | 3539 | const value = !!$(this).prop('checked'); |
| 3562 | 3540 | power_user.message_token_count_enabled = value; |
| 3563 | - localStorage.setItem(storage_keys.message_token_count_enabled, Boolean(power_user.message_token_count_enabled)); | |
| 3541 | + saveSettingsDebounced(); | |
| 3564 | 3542 | switchTokenCount(); |
| 3565 | 3543 | }); |
| 3566 | 3544 | |
| @@ -3823,14 +3801,12 @@ $(document).ready(() => { | ||
| 3823 | 3801 | |
| 3824 | 3802 | $('#reduced_motion').on('input', function () { |
| 3825 | 3803 | power_user.reduced_motion = !!$(this).prop('checked'); |
| 3826 | - localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion)); | |
| 3827 | 3804 | switchReducedMotion(); |
| 3828 | 3805 | saveSettingsDebounced(); |
| 3829 | 3806 | }); |
| 3830 | 3807 | |
| 3831 | 3808 | $('#compact_input_area').on('input', function () { |
| 3832 | 3809 | power_user.compact_input_area = !!$(this).prop('checked'); |
| 3833 | - localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area)); | |
| 3834 | 3810 | switchCompactInputArea(); |
| 3835 | 3811 | saveSettingsDebounced(); |
| 3836 | 3812 | }); |