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