Merge pull request #2706 from d-ber/saveMoreSettings

Save more settings
This commit is contained in:
Cohee
2024-08-25 11:59:35 +03:00
committed by GitHub
2 changed files with 40 additions and 188 deletions

View File

@ -84,6 +84,7 @@ import {
context_presets, context_presets,
resetMovableStyles, resetMovableStyles,
forceCharacterEditorTokenize, forceCharacterEditorTokenize,
applyPowerUserSettings,
} from './scripts/power-user.js'; } from './scripts/power-user.js';
import { import {
@ -6459,6 +6460,8 @@ export async function getSettings() {
// Load power user settings // Load power user settings
await loadPowerUserSettings(settings, data); await loadPowerUserSettings(settings, data);
applyPowerUserSettings();
// Load character tags // Load character tags
loadTagsSettings(settings); loadTagsSettings(settings);

View File

@ -60,6 +60,7 @@ export {
power_user, power_user,
send_on_enter_options, send_on_enter_options,
getContextSettings, getContextSettings,
applyPowerUserSettings,
}; };
export const MAX_CONTEXT_DEFAULT = 8192; export const MAX_CONTEXT_DEFAULT = 8192;
@ -301,43 +302,6 @@ let movingUIPresets = [];
export let context_presets = []; export let context_presets = [];
const storage_keys = { const storage_keys = {
fast_ui_mode: 'TavernAI_fast_ui_mode',
avatar_style: 'TavernAI_avatar_style',
chat_display: 'TavernAI_chat_display',
chat_width: 'chat_width',
font_scale: 'TavernAI_font_scale',
main_text_color: 'TavernAI_main_text_color',
italics_text_color: 'TavernAI_italics_text_color',
underline_text_color: 'TavernAI_underline_text_color',
quote_text_color: 'TavernAI_quote_text_color',
blur_tint_color: 'TavernAI_blur_tint_color',
chat_tint_color: 'TavernAI_chat_tint_color',
user_mes_blur_tint_color: 'TavernAI_user_mes_blur_tint_color',
bot_mes_blur_tint_color: 'TavernAI_bot_mes_blur_tint_color',
blur_strength: 'TavernAI_blur_strength',
shadow_color: 'TavernAI_shadow_color',
shadow_width: 'TavernAI_shadow_width',
border_color: 'TavernAI_border_color',
custom_css: 'TavernAI_custom_css',
waifuMode: 'TavernAI_waifuMode',
movingUI: 'TavernAI_movingUI',
noShadows: 'TavernAI_noShadows',
hotswap_enabled: 'HotswapEnabled',
timer_enabled: 'TimerEnabled',
timestamps_enabled: 'TimestampsEnabled',
timestamp_model_icon: 'TimestampModelIcon',
mesIDDisplay_enabled: 'mesIDDisplayEnabled',
hideChatAvatars_enabled: 'hideChatAvatarsEnabled',
message_token_count_enabled: 'MessageTokenCountEnabled',
expand_message_actions: 'ExpandMessageActions',
enableZenSliders: 'enableZenSliders',
enableLabMode: 'enableLabMode',
reduced_motion: 'reduced_motion',
compact_input_area: 'compact_input_area',
auto_connect_legacy: 'AutoConnectEnabled', auto_connect_legacy: 'AutoConnectEnabled',
auto_load_chat_legacy: 'AutoLoadChatEnabled', auto_load_chat_legacy: 'AutoLoadChatEnabled',
@ -459,73 +423,47 @@ function fixMarkdown(text, forDisplay) {
} }
function switchHotswap() { function switchHotswap() {
const value = localStorage.getItem(storage_keys.hotswap_enabled);
power_user.hotswap_enabled = value === null ? true : value == 'true';
$('body').toggleClass('no-hotswap', !power_user.hotswap_enabled); $('body').toggleClass('no-hotswap', !power_user.hotswap_enabled);
$('#hotswapEnabled').prop('checked', power_user.hotswap_enabled); $('#hotswapEnabled').prop('checked', power_user.hotswap_enabled);
} }
function switchTimer() { function switchTimer() {
const value = localStorage.getItem(storage_keys.timer_enabled);
power_user.timer_enabled = value === null ? true : value == 'true';
$('body').toggleClass('no-timer', !power_user.timer_enabled); $('body').toggleClass('no-timer', !power_user.timer_enabled);
$('#messageTimerEnabled').prop('checked', power_user.timer_enabled); $('#messageTimerEnabled').prop('checked', power_user.timer_enabled);
} }
function switchTimestamps() { function switchTimestamps() {
const value = localStorage.getItem(storage_keys.timestamps_enabled);
power_user.timestamps_enabled = value === null ? true : value == 'true';
$('body').toggleClass('no-timestamps', !power_user.timestamps_enabled); $('body').toggleClass('no-timestamps', !power_user.timestamps_enabled);
$('#messageTimestampsEnabled').prop('checked', power_user.timestamps_enabled); $('#messageTimestampsEnabled').prop('checked', power_user.timestamps_enabled);
} }
function switchIcons() { function switchIcons() {
const value = localStorage.getItem(storage_keys.timestamp_model_icon);
power_user.timestamp_model_icon = value === null ? true : value == 'true';
$('body').toggleClass('no-modelIcons', !power_user.timestamp_model_icon); $('body').toggleClass('no-modelIcons', !power_user.timestamp_model_icon);
$('#messageModelIconEnabled').prop('checked', power_user.timestamp_model_icon); $('#messageModelIconEnabled').prop('checked', power_user.timestamp_model_icon);
} }
function switchTokenCount() { function switchTokenCount() {
const value = localStorage.getItem(storage_keys.message_token_count_enabled);
power_user.message_token_count_enabled = value === null ? false : value == 'true';
$('body').toggleClass('no-tokenCount', !power_user.message_token_count_enabled); $('body').toggleClass('no-tokenCount', !power_user.message_token_count_enabled);
$('#messageTokensEnabled').prop('checked', power_user.message_token_count_enabled); $('#messageTokensEnabled').prop('checked', power_user.message_token_count_enabled);
} }
function switchMesIDDisplay() { function switchMesIDDisplay() {
const value = localStorage.getItem(storage_keys.mesIDDisplay_enabled);
power_user.mesIDDisplay_enabled = value === null ? true : value == 'true';
/* console.log(`
localstorage value:${value},
poweruser before:${before},
poweruser after:${power_user.mesIDDisplay_enabled}`) */
$('body').toggleClass('no-mesIDDisplay', !power_user.mesIDDisplay_enabled); $('body').toggleClass('no-mesIDDisplay', !power_user.mesIDDisplay_enabled);
$('#mesIDDisplayEnabled').prop('checked', power_user.mesIDDisplay_enabled); $('#mesIDDisplayEnabled').prop('checked', power_user.mesIDDisplay_enabled);
} }
function switchHideChatAvatars() { function switchHideChatAvatars() {
const value = localStorage.getItem(storage_keys.hideChatAvatars_enabled);
power_user.hideChatAvatars_enabled = value === null ? false : value == 'true';
/*console.log(`
localstorage value:${value},
poweruser after:${power_user.hideChatAvatars_enabled}`)
*/
$('body').toggleClass('hideChatAvatars', power_user.hideChatAvatars_enabled); $('body').toggleClass('hideChatAvatars', power_user.hideChatAvatars_enabled);
$('#hideChatAvatarsEnabled').prop('checked', power_user.hideChatAvatars_enabled); $('#hideChatAvatarsEnabled').prop('checked', power_user.hideChatAvatars_enabled);
} }
function switchMessageActions() { function switchMessageActions() {
const value = localStorage.getItem(storage_keys.expand_message_actions);
power_user.expand_message_actions = value === null ? false : value == 'true';
$('body').toggleClass('expandMessageActions', power_user.expand_message_actions); $('body').toggleClass('expandMessageActions', power_user.expand_message_actions);
$('#expandMessageActions').prop('checked', power_user.expand_message_actions); $('#expandMessageActions').prop('checked', power_user.expand_message_actions);
$('.extraMesButtons, .extraMesButtonsHint').removeAttr('style'); $('.extraMesButtons, .extraMesButtonsHint').removeAttr('style');
} }
function switchReducedMotion() { function switchReducedMotion() {
const value = localStorage.getItem(storage_keys.reduced_motion);
power_user.reduced_motion = value === null ? false : value == 'true';
jQuery.fx.off = power_user.reduced_motion; jQuery.fx.off = power_user.reduced_motion;
const overrideDuration = power_user.reduced_motion ? 0 : ANIMATION_DURATION_DEFAULT; const overrideDuration = power_user.reduced_motion ? 0 : ANIMATION_DURATION_DEFAULT;
setAnimationDuration(overrideDuration); setAnimationDuration(overrideDuration);
@ -534,8 +472,6 @@ function switchReducedMotion() {
} }
function switchCompactInputArea() { function switchCompactInputArea() {
const value = localStorage.getItem(storage_keys.compact_input_area);
power_user.compact_input_area = value === null ? true : value == 'true';
$('#send_form').toggleClass('compact', power_user.compact_input_area); $('#send_form').toggleClass('compact', power_user.compact_input_area);
$('#compact_input_area').prop('checked', power_user.compact_input_area); $('#compact_input_area').prop('checked', power_user.compact_input_area);
} }
@ -551,8 +487,6 @@ async function switchLabMode() {
} }
*/ */
await delay(100); await delay(100);
const value = localStorage.getItem(storage_keys.enableLabMode);
power_user.enableLabMode = value === null ? false : value == 'true';
$('body').toggleClass('enableLabMode', power_user.enableLabMode); $('body').toggleClass('enableLabMode', power_user.enableLabMode);
$('#enableLabMode').prop('checked', power_user.enableLabMode); $('#enableLabMode').prop('checked', power_user.enableLabMode);
@ -599,8 +533,6 @@ async function switchLabMode() {
async function switchZenSliders() { async function switchZenSliders() {
await delay(100); await delay(100);
const value = localStorage.getItem(storage_keys.enableZenSliders);
power_user.enableZenSliders = value === null ? false : value == 'true';
$('body').toggleClass('enableZenSliders', power_user.enableZenSliders); $('body').toggleClass('enableZenSliders', power_user.enableZenSliders);
$('#enableZenSliders').prop('checked', power_user.enableZenSliders); $('#enableZenSliders').prop('checked', power_user.enableZenSliders);
@ -972,8 +904,6 @@ async function CreateZenSliders(elmnt) {
} }
} }
function switchUiMode() { function switchUiMode() {
const fastUi = localStorage.getItem(storage_keys.fast_ui_mode);
power_user.fast_ui_mode = fastUi === null ? true : fastUi == 'true';
$('body').toggleClass('no-blur', power_user.fast_ui_mode); $('body').toggleClass('no-blur', power_user.fast_ui_mode);
$('#fast_ui_mode').prop('checked', power_user.fast_ui_mode); $('#fast_ui_mode').prop('checked', power_user.fast_ui_mode);
if (power_user.fast_ui_mode) { if (power_user.fast_ui_mode) {
@ -1023,8 +953,6 @@ function switchMovingUI() {
$('.drawer-content.maximized').each(function () { $('.drawer-content.maximized').each(function () {
$(this).find('.inline-drawer-maximize').trigger('click'); $(this).find('.inline-drawer-maximize').trigger('click');
}); });
const movingUI = localStorage.getItem(storage_keys.movingUI);
power_user.movingUI = movingUI === null ? false : movingUI == 'true';
$('body').toggleClass('movingUI', power_user.movingUI); $('body').toggleClass('movingUI', power_user.movingUI);
if (power_user.movingUI === true) { if (power_user.movingUI === true) {
initMovingUI(); initMovingUI();
@ -1040,9 +968,7 @@ function switchMovingUI() {
} }
} }
function noShadows() { function applyNoShadows() {
const noShadows = localStorage.getItem(storage_keys.noShadows);
power_user.noShadows = noShadows === null ? false : noShadows == 'true';
$('body').toggleClass('noShadows', power_user.noShadows); $('body').toggleClass('noShadows', power_user.noShadows);
$('#noShadowsmode').prop('checked', power_user.noShadows); $('#noShadowsmode').prop('checked', power_user.noShadows);
if (power_user.noShadows) { if (power_user.noShadows) {
@ -1056,12 +982,9 @@ function noShadows() {
} }
function applyAvatarStyle() { function applyAvatarStyle() {
power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND);
$('body').toggleClass('big-avatars', power_user.avatar_style === avatar_styles.RECTANGULAR); $('body').toggleClass('big-avatars', power_user.avatar_style === avatar_styles.RECTANGULAR);
$('body').toggleClass('square-avatars', power_user.avatar_style === avatar_styles.SQUARE); $('body').toggleClass('square-avatars', power_user.avatar_style === avatar_styles.SQUARE);
$('#avatar_style').val(power_user.avatar_style).prop('selected', true); $('#avatar_style').val(power_user.avatar_style).prop('selected', true);
//$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
} }
function applyChatDisplay() { function applyChatDisplay() {
@ -1096,8 +1019,6 @@ function applyChatDisplay() {
} }
function applyChatWidth(type) { function applyChatWidth(type) {
power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50);
if (type === 'forced') { if (type === 'forced') {
let r = document.documentElement; let r = document.documentElement;
r.style.setProperty('--sheldWidth', `${power_user.chat_width}vw`); r.style.setProperty('--sheldWidth', `${power_user.chat_width}vw`);
@ -1159,8 +1080,6 @@ async function applyThemeColor(type) {
} }
async function applyCustomCSS() { async function applyCustomCSS() {
power_user.custom_css = String(localStorage.getItem(storage_keys.custom_css) ?? '');
$('#customCSS').val(power_user.custom_css); $('#customCSS').val(power_user.custom_css);
var styleId = 'custom-style'; var styleId = 'custom-style';
var style = document.getElementById(styleId); var style = document.getElementById(styleId);
@ -1174,32 +1093,26 @@ async function applyCustomCSS() {
} }
async function applyBlurStrength() { async function applyBlurStrength() {
power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 1); document.documentElement.style.setProperty('--blurStrength', String(power_user.blur_strength));
document.documentElement.style.setProperty('--blurStrength', power_user.blur_strength);
$('#blur_strength_counter').val(power_user.blur_strength); $('#blur_strength_counter').val(power_user.blur_strength);
$('#blur_strength').val(power_user.blur_strength); $('#blur_strength').val(power_user.blur_strength);
} }
async function applyShadowWidth() { async function applyShadowWidth() {
power_user.shadow_width = Number(localStorage.getItem(storage_keys.shadow_width) ?? 2); document.documentElement.style.setProperty('--shadowWidth', String(power_user.shadow_width));
document.documentElement.style.setProperty('--shadowWidth', power_user.shadow_width);
$('#shadow_width_counter').val(power_user.shadow_width); $('#shadow_width_counter').val(power_user.shadow_width);
$('#shadow_width').val(power_user.shadow_width); $('#shadow_width').val(power_user.shadow_width);
} }
async function applyFontScale(type) { async function applyFontScale(type) {
power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1);
//this is to allow forced setting on page load, theme swap, etc //this is to allow forced setting on page load, theme swap, etc
if (type === 'forced') { if (type === 'forced') {
document.documentElement.style.setProperty('--fontScale', power_user.font_scale); document.documentElement.style.setProperty('--fontScale', String(power_user.font_scale));
} else { } else {
//this is to prevent the slider from updating page in real time //this is to prevent the slider from updating page in real time
$('#font_scale').off('mouseup touchend').on('mouseup touchend', () => { $('#font_scale').off('mouseup touchend').on('mouseup touchend', () => {
document.documentElement.style.setProperty('--fontScale', power_user.font_scale); document.documentElement.style.setProperty('--fontScale', String(power_user.font_scale));
}); });
} }
@ -1228,64 +1141,55 @@ async function applyTheme(name) {
{ {
key: 'blur_strength', key: 'blur_strength',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength);
await applyBlurStrength(); await applyBlurStrength();
}, },
}, },
{ {
key: 'custom_css', key: 'custom_css',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.custom_css, power_user.custom_css);
await applyCustomCSS(); await applyCustomCSS();
}, },
}, },
{ {
key: 'shadow_width', key: 'shadow_width',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.shadow_width, power_user.shadow_width);
await applyShadowWidth(); await applyShadowWidth();
}, },
}, },
{ {
key: 'font_scale', key: 'font_scale',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.font_scale, power_user.font_scale);
await applyFontScale('forced'); await applyFontScale('forced');
}, },
}, },
{ {
key: 'fast_ui_mode', key: 'fast_ui_mode',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.fast_ui_mode, power_user.fast_ui_mode);
switchUiMode(); switchUiMode();
}, },
}, },
{ {
key: 'waifuMode', key: 'waifuMode',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.waifuMode, power_user.waifuMode);
switchWaifuMode(); switchWaifuMode();
}, },
}, },
{ {
key: 'chat_display', key: 'chat_display',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.chat_display, power_user.chat_display);
applyChatDisplay(); applyChatDisplay();
}, },
}, },
{ {
key: 'avatar_style', key: 'avatar_style',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.avatar_style, power_user.avatar_style);
applyAvatarStyle(); applyAvatarStyle();
}, },
}, },
{ {
key: 'noShadows', key: 'noShadows',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.noShadows, power_user.noShadows); applyNoShadows();
noShadows();
}, },
}, },
{ {
@ -1295,78 +1199,66 @@ async function applyTheme(name) {
if (!power_user.chat_width) { if (!power_user.chat_width) {
power_user.chat_width = 50; power_user.chat_width = 50;
} }
localStorage.setItem(storage_keys.chat_width, String(power_user.chat_width));
applyChatWidth('forced'); applyChatWidth('forced');
}, },
}, },
{ {
key: 'timer_enabled', key: 'timer_enabled',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.timer_enabled, Boolean(power_user.timer_enabled));
switchTimer(); switchTimer();
}, },
}, },
{ {
key: 'timestamps_enabled', key: 'timestamps_enabled',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.timestamps_enabled, Boolean(power_user.timestamps_enabled));
switchTimestamps(); switchTimestamps();
}, },
}, },
{ {
key: 'timestamp_model_icon', key: 'timestamp_model_icon',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon));
switchIcons(); switchIcons();
}, },
}, },
{ {
key: 'message_token_count_enabled', key: 'message_token_count_enabled',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.message_token_count_enabled, Boolean(power_user.message_token_count_enabled));
switchTokenCount(); switchTokenCount();
}, },
}, },
{ {
key: 'mesIDDisplay_enabled', key: 'mesIDDisplay_enabled',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.mesIDDisplay_enabled, Boolean(power_user.mesIDDisplay_enabled));
switchMesIDDisplay(); switchMesIDDisplay();
}, },
}, },
{ {
key: 'hideChatAvatars_enabled', key: 'hideChatAvatars_enabled',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.hideChatAvatars_enabled, Boolean(power_user.hideChatAvatars_enabled));
switchHideChatAvatars(); switchHideChatAvatars();
}, },
}, },
{ {
key: 'expand_message_actions', key: 'expand_message_actions',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.expand_message_actions, Boolean(power_user.expand_message_actions));
switchMessageActions(); switchMessageActions();
}, },
}, },
{ {
key: 'enableZenSliders', key: 'enableZenSliders',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.enableZenSliders, Boolean(power_user.enableZenSliders));
switchMessageActions(); switchMessageActions();
}, },
}, },
{ {
key: 'enableLabMode', key: 'enableLabMode',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode));
switchMessageActions(); switchMessageActions();
}, },
}, },
{ {
key: 'hotswap_enabled', key: 'hotswap_enabled',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.hotswap_enabled, Boolean(power_user.hotswap_enabled));
switchHotswap(); switchHotswap();
}, },
}, },
@ -1387,7 +1279,6 @@ async function applyTheme(name) {
{ {
key: 'reduced_motion', key: 'reduced_motion',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion));
$('#reduced_motion').prop('checked', power_user.reduced_motion); $('#reduced_motion').prop('checked', power_user.reduced_motion);
switchReducedMotion(); switchReducedMotion();
}, },
@ -1395,7 +1286,6 @@ async function applyTheme(name) {
{ {
key: 'compact_input_area', key: 'compact_input_area',
action: async () => { action: async () => {
localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area));
$('#compact_input_area').prop('checked', power_user.compact_input_area); $('#compact_input_area').prop('checked', power_user.compact_input_area);
switchCompactInputArea(); switchCompactInputArea();
}, },
@ -1450,24 +1340,26 @@ async function showDebugMenu() {
callGenericPopup(template, POPUP_TYPE.TEXT, '', { wide: true, large: true, allowVerticalScrolling: true }); callGenericPopup(template, POPUP_TYPE.TEXT, '', { wide: true, large: true, allowVerticalScrolling: true });
} }
switchUiMode(); function applyPowerUserSettings() {
applyFontScale('forced'); switchUiMode();
applyThemeColor(); applyFontScale('forced');
applyChatWidth('forced'); applyThemeColor();
applyAvatarStyle(); applyChatWidth('forced');
applyBlurStrength(); applyAvatarStyle();
applyShadowWidth(); applyBlurStrength();
applyCustomCSS(); applyShadowWidth();
switchMovingUI(); applyCustomCSS();
noShadows(); switchMovingUI();
switchHotswap(); applyNoShadows();
switchTimer(); switchHotswap();
switchTimestamps(); switchTimer();
switchIcons(); switchTimestamps();
switchMesIDDisplay(); switchIcons();
switchHideChatAvatars(); switchMesIDDisplay();
switchTokenCount(); switchHideChatAvatars();
switchMessageActions(); switchTokenCount();
switchMessageActions();
}
function getExampleMessagesBehavior() { function getExampleMessagesBehavior() {
if (power_user.strip_examples) { if (power_user.strip_examples) {
@ -1531,17 +1423,6 @@ async function loadPowerUserSettings(settings, data) {
} }
// These are still local storage // These are still local storage
const fastUi = localStorage.getItem(storage_keys.fast_ui_mode);
const movingUI = localStorage.getItem(storage_keys.movingUI);
const noShadows = localStorage.getItem(storage_keys.noShadows);
const hotswap = localStorage.getItem(storage_keys.hotswap_enabled);
const timer = localStorage.getItem(storage_keys.timer_enabled);
const timestamps = localStorage.getItem(storage_keys.timestamps_enabled);
const mesIDDisplay = localStorage.getItem(storage_keys.mesIDDisplay_enabled);
const hideChatAvatars = localStorage.getItem(storage_keys.hideChatAvatars_enabled);
const expandMessageActions = localStorage.getItem(storage_keys.expand_message_actions);
const enableZenSliders = localStorage.getItem(storage_keys.enableZenSliders);
const enableLabMode = localStorage.getItem(storage_keys.enableLabMode);
const autoLoadChat = localStorage.getItem(storage_keys.auto_load_chat_legacy); const autoLoadChat = localStorage.getItem(storage_keys.auto_load_chat_legacy);
const autoConnect = localStorage.getItem(storage_keys.auto_connect_legacy); const autoConnect = localStorage.getItem(storage_keys.auto_connect_legacy);
@ -1555,23 +1436,6 @@ async function loadPowerUserSettings(settings, data) {
localStorage.removeItem(storage_keys.auto_connect_legacy); localStorage.removeItem(storage_keys.auto_connect_legacy);
} }
power_user.fast_ui_mode = fastUi === null ? true : fastUi == 'true';
power_user.movingUI = movingUI === null ? false : movingUI == 'true';
power_user.noShadows = noShadows === null ? false : noShadows == 'true';
power_user.hotswap_enabled = hotswap === null ? true : hotswap == 'true';
power_user.timer_enabled = timer === null ? true : timer == 'true';
power_user.timestamps_enabled = timestamps === null ? true : timestamps == 'true';
power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == 'true';
power_user.hideChatAvatars_enabled = hideChatAvatars === null ? true : hideChatAvatars == 'true';
power_user.expand_message_actions = expandMessageActions === null ? true : expandMessageActions == 'true';
power_user.enableZenSliders = enableZenSliders === null ? false : enableZenSliders == 'true';
power_user.enableLabMode = enableLabMode === null ? false : enableLabMode == 'true';
power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND);
//power_user.chat_display = Number(localStorage.getItem(storage_keys.chat_display) ?? chat_styles.DEFAULT);
power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50);
power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1);
power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10);
if (power_user.chat_display === '') { if (power_user.chat_display === '') {
power_user.chat_display = chat_styles.DEFAULT; power_user.chat_display = chat_styles.DEFAULT;
} }
@ -3298,10 +3162,8 @@ $(document).ready(() => {
saveSettingsDebounced(); saveSettingsDebounced();
}); });
// Settings that go to local storage
$('#fast_ui_mode').change(function () { $('#fast_ui_mode').change(function () {
power_user.fast_ui_mode = $(this).prop('checked'); power_user.fast_ui_mode = $(this).prop('checked');
localStorage.setItem(storage_keys.fast_ui_mode, power_user.fast_ui_mode);
switchUiMode(); switchUiMode();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
@ -3314,22 +3176,19 @@ $(document).ready(() => {
$('#customCSS').on('input', () => { $('#customCSS').on('input', () => {
power_user.custom_css = String($('#customCSS').val()); power_user.custom_css = String($('#customCSS').val());
localStorage.setItem(storage_keys.custom_css, power_user.custom_css);
saveSettingsDebounced(); saveSettingsDebounced();
applyCustomCSS(); applyCustomCSS();
}); });
$('#movingUImode').change(function () { $('#movingUImode').change(function () {
power_user.movingUI = $(this).prop('checked'); power_user.movingUI = $(this).prop('checked');
localStorage.setItem(storage_keys.movingUI, power_user.movingUI);
switchMovingUI(); switchMovingUI();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$('#noShadowsmode').change(function () { $('#noShadowsmode').change(function () {
power_user.noShadows = $(this).prop('checked'); power_user.noShadows = $(this).prop('checked');
localStorage.setItem(storage_keys.noShadows, power_user.noShadows); applyNoShadows();
noShadows();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
@ -3338,7 +3197,6 @@ $(document).ready(() => {
$('#avatar_style').on('change', function () { $('#avatar_style').on('change', function () {
const value = $(this).find(':selected').val(); const value = $(this).find(':selected').val();
power_user.avatar_style = Number(value); power_user.avatar_style = Number(value);
localStorage.setItem(storage_keys.avatar_style, power_user.avatar_style);
applyAvatarStyle(); applyAvatarStyle();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
@ -3346,17 +3204,15 @@ $(document).ready(() => {
$('#chat_display').on('change', function () { $('#chat_display').on('change', function () {
const value = $(this).find(':selected').val(); const value = $(this).find(':selected').val();
power_user.chat_display = Number(value); power_user.chat_display = Number(value);
localStorage.setItem(storage_keys.chat_display, power_user.chat_display);
applyChatDisplay(); applyChatDisplay();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$('#chat_width_slider').on('input', function (e, data) { $('#chat_width_slider').on('input', function (e, data) {
const applyMode = data?.forced ? 'forced' : 'normal'; const applyMode = data?.forced ? 'forced' : 'normal';
power_user.chat_width = Number(e.target.value); power_user.chat_width = Number(e.target.value);
localStorage.setItem(storage_keys.chat_width, power_user.chat_width);
applyChatWidth(applyMode); applyChatWidth(applyMode);
saveSettingsDebounced();
setHotswapsDebounced(); setHotswapsDebounced();
}); });
@ -3386,7 +3242,6 @@ $(document).ready(() => {
const applyMode = data?.forced ? 'forced' : 'normal'; const applyMode = data?.forced ? 'forced' : 'normal';
power_user.font_scale = Number(e.target.value); power_user.font_scale = Number(e.target.value);
$('#font_scale_counter').val(power_user.font_scale); $('#font_scale_counter').val(power_user.font_scale);
localStorage.setItem(storage_keys.font_scale, power_user.font_scale);
await applyFontScale(applyMode); await applyFontScale(applyMode);
saveSettingsDebounced(); saveSettingsDebounced();
}); });
@ -3394,7 +3249,6 @@ $(document).ready(() => {
$('input[name="blur_strength"]').on('input', async function (e) { $('input[name="blur_strength"]').on('input', async function (e) {
power_user.blur_strength = Number(e.target.value); power_user.blur_strength = Number(e.target.value);
$('#blur_strength_counter').val(power_user.blur_strength); $('#blur_strength_counter').val(power_user.blur_strength);
localStorage.setItem(storage_keys.blur_strength, power_user.blur_strength);
await applyBlurStrength(); await applyBlurStrength();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
@ -3402,7 +3256,6 @@ $(document).ready(() => {
$('input[name="shadow_width"]').on('input', async function (e) { $('input[name="shadow_width"]').on('input', async function (e) {
power_user.shadow_width = Number(e.target.value); power_user.shadow_width = Number(e.target.value);
$('#shadow_width_counter').val(power_user.shadow_width); $('#shadow_width_counter').val(power_user.shadow_width);
localStorage.setItem(storage_keys.shadow_width, power_user.shadow_width);
await applyShadowWidth(); await applyShadowWidth();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
@ -3643,35 +3496,35 @@ $(document).ready(() => {
$('#messageTimerEnabled').on('input', function () { $('#messageTimerEnabled').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.timer_enabled = value; power_user.timer_enabled = value;
localStorage.setItem(storage_keys.timer_enabled, Boolean(power_user.timer_enabled)); saveSettingsDebounced();
switchTimer(); switchTimer();
}); });
$('#messageTimestampsEnabled').on('input', function () { $('#messageTimestampsEnabled').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.timestamps_enabled = value; power_user.timestamps_enabled = value;
localStorage.setItem(storage_keys.timestamps_enabled, Boolean(power_user.timestamps_enabled)); saveSettingsDebounced();
switchTimestamps(); switchTimestamps();
}); });
$('#messageModelIconEnabled').on('input', function () { $('#messageModelIconEnabled').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.timestamp_model_icon = value; power_user.timestamp_model_icon = value;
localStorage.setItem(storage_keys.timestamp_model_icon, Boolean(power_user.timestamp_model_icon)); saveSettingsDebounced();
switchIcons(); switchIcons();
}); });
$('#messageTokensEnabled').on('input', function () { $('#messageTokensEnabled').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.message_token_count_enabled = value; power_user.message_token_count_enabled = value;
localStorage.setItem(storage_keys.message_token_count_enabled, Boolean(power_user.message_token_count_enabled)); saveSettingsDebounced();
switchTokenCount(); switchTokenCount();
}); });
$('#expandMessageActions').on('input', function () { $('#expandMessageActions').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.expand_message_actions = value; power_user.expand_message_actions = value;
localStorage.setItem(storage_keys.expand_message_actions, Boolean(power_user.expand_message_actions)); saveSettingsDebounced();
switchMessageActions(); switchMessageActions();
}); });
@ -3684,7 +3537,6 @@ $(document).ready(() => {
return; return;
} }
power_user.enableZenSliders = value; power_user.enableZenSliders = value;
localStorage.setItem(storage_keys.enableZenSliders, Boolean(power_user.enableZenSliders));
saveSettingsDebounced(); saveSettingsDebounced();
switchZenSliders(); switchZenSliders();
}); });
@ -3699,7 +3551,6 @@ $(document).ready(() => {
} }
power_user.enableLabMode = value; power_user.enableLabMode = value;
localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode));
saveSettingsDebounced(); saveSettingsDebounced();
switchLabMode(); switchLabMode();
}); });
@ -3707,22 +3558,22 @@ $(document).ready(() => {
$('#mesIDDisplayEnabled').on('input', function () { $('#mesIDDisplayEnabled').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.mesIDDisplay_enabled = value; power_user.mesIDDisplay_enabled = value;
localStorage.setItem(storage_keys.mesIDDisplay_enabled, Boolean(power_user.mesIDDisplay_enabled)); saveSettingsDebounced();
switchMesIDDisplay(); switchMesIDDisplay();
}); });
$('#hideChatAvatarsEnabled').on('input', function () { $('#hideChatAvatarsEnabled').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.hideChatAvatars_enabled = value; power_user.hideChatAvatars_enabled = value;
localStorage.setItem(storage_keys.hideChatAvatars_enabled, Boolean(power_user.hideChatAvatars_enabled)); saveSettingsDebounced();
switchHideChatAvatars(); switchHideChatAvatars();
}); });
$('#hotswapEnabled').on('input', function () { $('#hotswapEnabled').on('input', function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.hotswap_enabled = value; power_user.hotswap_enabled = value;
localStorage.setItem(storage_keys.hotswap_enabled, Boolean(power_user.hotswap_enabled));
switchHotswap(); switchHotswap();
saveSettingsDebounced();
}); });
$('#prefer_character_prompt').on('input', function () { $('#prefer_character_prompt').on('input', function () {
@ -3935,14 +3786,12 @@ $(document).ready(() => {
$('#reduced_motion').on('input', function () { $('#reduced_motion').on('input', function () {
power_user.reduced_motion = !!$(this).prop('checked'); power_user.reduced_motion = !!$(this).prop('checked');
localStorage.setItem(storage_keys.reduced_motion, String(power_user.reduced_motion));
switchReducedMotion(); switchReducedMotion();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$('#compact_input_area').on('input', function () { $('#compact_input_area').on('input', function () {
power_user.compact_input_area = !!$(this).prop('checked'); power_user.compact_input_area = !!$(this).prop('checked');
localStorage.setItem(storage_keys.compact_input_area, String(power_user.compact_input_area));
switchCompactInputArea(); switchCompactInputArea();
saveSettingsDebounced(); saveSettingsDebounced();
}); });