This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-11 12:50:50 -06:00
1 parent 724d2ebbf1
commit 1674e5a9ef
2 files changed
+34 -9

No files matched your search

@@ -63,6 +63,23 @@
let tabState: Record<string, unknown> | null = null; let tabState: Record<string, unknown> | null = null;
let personalUiSettings: Record<string, any> = {}; let personalUiSettings: Record<string, any> = {};
const mergeUiSettings = (defaults: Record<string, any>, userSettings: Record<string, any>) => {
const merged = { ...defaults };
for (const [key, value] of Object.entries(userSettings)) {
const defaultValue = merged[key];
merged[key] =
defaultValue &&
value &&
typeof defaultValue === 'object' &&
typeof value === 'object' &&
!Array.isArray(defaultValue) &&
!Array.isArray(value)
? mergeUiSettings(defaultValue, value)
: value;
}
return merged;
};
const loadPersonalUiSettings = async () => { const loadPersonalUiSettings = async () => {
const userSettings = await getUserSettings(localStorage.token, true).catch((error) => { const userSettings = await getUserSettings(localStorage.token, true).catch((error) => {
console.error(error); console.error(error);
@@ -838,6 +855,9 @@
const saved = await updateUserSettings(localStorage.token, { ui: $settings }); const saved = await updateUserSettings(localStorage.token, { ui: $settings });
personalUiSettings = personalUiSettings =
saved?.ui && typeof saved.ui === 'object' && !Array.isArray(saved.ui) ? saved.ui : {}; saved?.ui && typeof saved.ui === 'object' && !Array.isArray(saved.ui) ? saved.ui : {};
await settings.set(
mergeUiSettings($config?.ui?.default_interface_settings ?? {}, personalUiSettings)
);
}; };
const getModels = async () => { const getModels = async () => {
@@ -111,6 +111,7 @@
let showManageImageCompressionModal = false; let showManageImageCompressionModal = false;
let textScale: number | null = null; let textScale: number | null = null;
let showTextScaleSlider = false;
const settingRowClass = 'flex items-center justify-between gap-2.5'; const settingRowClass = 'flex items-center justify-between gap-2.5';
const settingLabelClass = 'min-w-0 text-xs text-gray-600 dark:text-gray-400'; const settingLabelClass = 'min-w-0 text-xs text-gray-600 dark:text-gray-400';
const settingControlClass = 'flex shrink-0 items-center justify-end gap-1.5'; const settingControlClass = 'flex shrink-0 items-center justify-end gap-1.5';
@@ -243,9 +244,6 @@
setTextScale(textScale); setTextScale(textScale);
} }
if (textScale === 1) {
textScale = null;
}
saveSettings({ textScale }); saveSettings({ textScale });
}; };
@@ -328,6 +326,7 @@
webSearch = currentSettings?.webSearch ?? null; webSearch = currentSettings?.webSearch ?? null;
textScale = currentSettings?.textScale ?? null; textScale = currentSettings?.textScale ?? null;
showTextScaleSlider = false;
defaultUploadContext = currentSettings?.defaultUploadContext ?? 'focused'; defaultUploadContext = currentSettings?.defaultUploadContext ?? 'focused';
}; };
@@ -401,14 +400,20 @@
aria-live="polite" aria-live="polite"
type="button" type="button"
on:click={() => { on:click={() => {
if (textScale === null) { if (textScale === null || (isDefaultSetting('textScale') && !showTextScaleSlider)) {
textScale = 1; textScale = textScale ?? defaultSettings.textScale ?? 1;
} else if (!isDefaultSetting('textScale')) { showTextScaleSlider = true;
setTextScaleHandler(defaultSettings.textScale ?? 1); } else {
showTextScaleSlider = false;
if (!externalSettings) {
setTextScale(defaultSettings.textScale ?? 1);
}
textScale = null;
saveSettings({ textScale });
} }
}} }}
> >
{#if textScale === null || isDefaultSetting('textScale')} {#if textScale === null || (isDefaultSetting('textScale') && !showTextScaleSlider)}
<span>{$i18n.t('Default')}</span> <span>{$i18n.t('Default')}</span>
{:else} {:else}
<span>{textScale}x</span> <span>{textScale}x</span>
@@ -417,7 +422,7 @@
</div> </div>
</div> </div>
{#if textScale !== null && !isDefaultSetting('textScale')} {#if textScale !== null && (showTextScaleSlider || !isDefaultSetting('textScale'))}
<div class=" flex items-center gap-2 px-1 pb-1"> <div class=" flex items-center gap-2 px-1 pb-1">
<button <button
type="button" type="button"