Use saved settings for more properties

cf828bca7116d4950aa44e6923049c37c4a84adb

d-ber <davide.bertalero@studenti.unimi.it>

1 files changed, +5 -29Showing whitespace changes
public/scripts/power-user.js+5 -29
@@ -301,8 +301,6 @@ let movingUIPresets = [];
301301export let context_presets = [];
302302
303303const storage_keys = {
304- chat_display: 'TavernAI_chat_display',
305-
306304 main_text_color: 'TavernAI_main_text_color',
307305 italics_text_color: 'TavernAI_italics_text_color',
308306 underline_text_color: 'TavernAI_underline_text_color',
@@ -317,12 +315,6 @@ const storage_keys = {
317315
318316 custom_css: 'TavernAI_custom_css',
319317
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',
326318 auto_connect_legacy: 'AutoConnectEnabled',
327319 auto_load_chat_legacy: 'AutoLoadChatEnabled',
328320
@@ -459,15 +451,11 @@ function switchTimestamps() {
459451}
460452
461453function switchIcons() {
462- const value = localStorage.getItem(storage_keys.timestamp_model_icon);
463- power_user.timestamp_model_icon = value === null ? true : value == 'true';
464454 $('body').toggleClass('no-modelIcons', !power_user.timestamp_model_icon);
465455 $('#messageModelIconEnabled').prop('checked', power_user.timestamp_model_icon);
466456}
467457
468458function switchTokenCount() {
469- const value = localStorage.getItem(storage_keys.message_token_count_enabled);
470- power_user.message_token_count_enabled = value === null ? false : value == 'true';
471459 $('body').toggleClass('no-tokenCount', !power_user.message_token_count_enabled);
472460 $('#messageTokensEnabled').prop('checked', power_user.message_token_count_enabled);
473461}
@@ -489,8 +477,6 @@ function switchMessageActions() {
489477}
490478
491479function switchReducedMotion() {
492- const value = localStorage.getItem(storage_keys.reduced_motion);
493- power_user.reduced_motion = value === null ? false : value == 'true';
494480 jQuery.fx.off = power_user.reduced_motion;
495481 const overrideDuration = power_user.reduced_motion ? 0 : ANIMATION_DURATION_DEFAULT;
496482 setAnimationDuration(overrideDuration);
@@ -499,8 +485,6 @@ function switchReducedMotion() {
499485}
500486
501487function switchCompactInputArea() {
502- const value = localStorage.getItem(storage_keys.compact_input_area);
503- power_user.compact_input_area = value === null ? true : value == 'true';
504488 $('#send_form').toggleClass('compact', power_user.compact_input_area);
505489 $('#compact_input_area').prop('checked', power_user.compact_input_area);
506490}
@@ -1205,14 +1189,12 @@ async function applyTheme(name) {
12051189 {
12061190 key: 'waifuMode',
12071191 action: async () => {
1208- localStorage.setItem(storage_keys.waifuMode, power_user.waifuMode);
12091192 switchWaifuMode();
12101193 },
12111194 },
12121195 {
12131196 key: 'chat_display',
12141197 action: async () => {
1215- localStorage.setItem(storage_keys.chat_display, power_user.chat_display);
12161198 applyChatDisplay();
12171199 },
12181200 },
@@ -1235,7 +1217,6 @@ async function applyTheme(name) {
12351217 if (!power_user.chat_width) {
12361218 power_user.chat_width = 50;
12371219 }
1238- saveSettingsDebounced();
12391220 applyChatWidth('forced');
12401221 },
12411222 },
@@ -1254,14 +1235,12 @@ async function applyTheme(name) {
12541235 {
12551236 key: 'timestamp_model_icon',
12561237 action: async () => {
1257- localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon));
12581238 switchIcons();
12591239 },
12601240 },
12611241 {
12621242 key: 'message_token_count_enabled',
12631243 action: async () => {
1264- localStorage.setItem(storage_keys.message_token_count_enabled, Boolean(power_user.message_token_count_enabled));
12651244 switchTokenCount();
12661245 },
12671246 },
@@ -1318,7 +1297,6 @@ async function applyTheme(name) {
13181297 {
13191298 key: 'reduced_motion',
13201299 action: async () => {
1321- localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion));
13221300 $('#reduced_motion').prop('checked', power_user.reduced_motion);
13231301 switchReducedMotion();
13241302 },
@@ -1326,7 +1304,6 @@ async function applyTheme(name) {
13261304 {
13271305 key: 'compact_input_area',
13281306 action: async () => {
1329- localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area));
13301307 $('#compact_input_area').prop('checked', power_user.compact_input_area);
13311308 switchCompactInputArea();
13321309 },
@@ -1486,6 +1463,10 @@ async function loadPowerUserSettings(settings, data) {
14861463 power_user.waifuMode = false;
14871464 }
14881465
1466+ if (power_user.chat_width === '') {
1467+ power_user.chat_width = 50;
1468+ }
1469+
14891470 if (power_user.tokenizer === tokenizers.LEGACY) {
14901471 power_user.tokenizer = tokenizers.GPT2;
14911472 }
@@ -3243,10 +3224,8 @@ $(document).ready(() => {
32433224 $('#chat_display').on('change', function () {
32443225 const value = $(this).find(':selected').val();
32453226 power_user.chat_display = Number(value);
3246- localStorage.setItem(storage_keys.chat_display, power_user.chat_display);
32473227 applyChatDisplay();
32483228 saveSettingsDebounced();
3249-
32503229 });
32513230
32523231 $('#chat_width_slider').on('input', function (e, data) {
@@ -3552,7 +3531,6 @@ $(document).ready(() => {
35523531 $('#messageModelIconEnabled').on('input', function () {
35533532 const value = !!$(this).prop('checked');
35543533 power_user.timestamp_model_icon = value;
3555- localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon));
35563534 saveSettingsDebounced();
35573535 switchIcons();
35583536 });
@@ -3560,7 +3538,7 @@ $(document).ready(() => {
35603538 $('#messageTokensEnabled').on('input', function () {
35613539 const value = !!$(this).prop('checked');
35623540 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();
35643542 switchTokenCount();
35653543 });
35663544
@@ -3823,14 +3801,12 @@ $(document).ready(() => {
38233801
38243802 $('#reduced_motion').on('input', function () {
38253803 power_user.reduced_motion = !!$(this).prop('checked');
3826- localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion));
38273804 switchReducedMotion();
38283805 saveSettingsDebounced();
38293806 });
38303807
38313808 $('#compact_input_area').on('input', function () {
38323809 power_user.compact_input_area = !!$(this).prop('checked');
3833- localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area));
38343810 switchCompactInputArea();
38353811 saveSettingsDebounced();
38363812 });