mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-29 18:30:15 +01:00
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.
This commit is contained in:
parent
3b46b5a46d
commit
d153991a11
@ -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 {
|
||||||
@ -6450,6 +6451,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);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
@ -300,8 +301,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_display: 'TavernAI_chat_display',
|
||||||
chat_width: 'chat_width',
|
chat_width: 'chat_width',
|
||||||
font_scale: 'TavernAI_font_scale',
|
font_scale: 'TavernAI_font_scale',
|
||||||
@ -323,9 +322,7 @@ const storage_keys = {
|
|||||||
|
|
||||||
waifuMode: 'TavernAI_waifuMode',
|
waifuMode: 'TavernAI_waifuMode',
|
||||||
movingUI: 'TavernAI_movingUI',
|
movingUI: 'TavernAI_movingUI',
|
||||||
noShadows: 'TavernAI_noShadows',
|
|
||||||
|
|
||||||
hotswap_enabled: 'HotswapEnabled',
|
|
||||||
timer_enabled: 'TimerEnabled',
|
timer_enabled: 'TimerEnabled',
|
||||||
timestamps_enabled: 'TimestampsEnabled',
|
timestamps_enabled: 'TimestampsEnabled',
|
||||||
timestamp_model_icon: 'TimestampModelIcon',
|
timestamp_model_icon: 'TimestampModelIcon',
|
||||||
@ -458,8 +455,6 @@ 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);
|
||||||
}
|
}
|
||||||
@ -971,8 +966,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) {
|
||||||
@ -1039,9 +1032,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) {
|
||||||
@ -1055,12 +1046,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() {
|
||||||
@ -1255,7 +1243,6 @@ async function applyTheme(name) {
|
|||||||
{
|
{
|
||||||
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();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1276,15 +1263,13 @@ async function applyTheme(name) {
|
|||||||
{
|
{
|
||||||
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();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1365,7 +1350,6 @@ async function applyTheme(name) {
|
|||||||
{
|
{
|
||||||
key: 'hotswap_enabled',
|
key: 'hotswap_enabled',
|
||||||
action: async () => {
|
action: async () => {
|
||||||
localStorage.setItem(storage_keys.hotswap_enabled, Boolean(power_user.hotswap_enabled));
|
|
||||||
switchHotswap();
|
switchHotswap();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1449,24 +1433,27 @@ 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) {
|
||||||
@ -1530,10 +1517,7 @@ 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 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 timer = localStorage.getItem(storage_keys.timer_enabled);
|
||||||
const timestamps = localStorage.getItem(storage_keys.timestamps_enabled);
|
const timestamps = localStorage.getItem(storage_keys.timestamps_enabled);
|
||||||
const mesIDDisplay = localStorage.getItem(storage_keys.mesIDDisplay_enabled);
|
const mesIDDisplay = localStorage.getItem(storage_keys.mesIDDisplay_enabled);
|
||||||
@ -1554,10 +1538,7 @@ 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.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.timer_enabled = timer === null ? true : timer == 'true';
|
||||||
power_user.timestamps_enabled = timestamps === null ? true : timestamps == 'true';
|
power_user.timestamps_enabled = timestamps === null ? true : timestamps == 'true';
|
||||||
power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == 'true';
|
power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == 'true';
|
||||||
@ -1565,8 +1546,6 @@ async function loadPowerUserSettings(settings, data) {
|
|||||||
power_user.expand_message_actions = expandMessageActions === null ? true : expandMessageActions == 'true';
|
power_user.expand_message_actions = expandMessageActions === null ? true : expandMessageActions == 'true';
|
||||||
power_user.enableZenSliders = enableZenSliders === null ? false : enableZenSliders == 'true';
|
power_user.enableZenSliders = enableZenSliders === null ? false : enableZenSliders == 'true';
|
||||||
power_user.enableLabMode = enableLabMode === null ? false : enableLabMode == '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.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50);
|
||||||
power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1);
|
power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1);
|
||||||
power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10);
|
power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10);
|
||||||
@ -3299,7 +3278,6 @@ $(document).ready(() => {
|
|||||||
// Settings that go to local storage
|
// 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();
|
||||||
});
|
});
|
||||||
@ -3326,8 +3304,7 @@ $(document).ready(() => {
|
|||||||
|
|
||||||
$('#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();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -3336,7 +3313,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();
|
||||||
});
|
});
|
||||||
@ -3719,8 +3695,8 @@ $(document).ready(() => {
|
|||||||
$('#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 () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user