diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index d1908af243..49b21aa35b 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1059,14 +1059,6 @@ $models.map((m) => m.id).includes(modelId) ? modelId : '' ); - const userSettings = await getUserSettings(localStorage.token); - - if (userSettings) { - settings.set(userSettings.ui); - } else { - settings.set(JSON.parse(localStorage.getItem('settings') ?? '{}')); - } - const chatInput = document.getElementById('chat-input'); setTimeout(() => chatInput?.focus(), 0); }; @@ -1111,14 +1103,6 @@ chatTitle.set(chatContent.title); - const userSettings = await getUserSettings(localStorage.token); - - if (userSettings) { - await settings.set(userSettings.ui); - } else { - await settings.set(JSON.parse(localStorage.getItem('settings') ?? '{}')); - } - params = chatContent?.params ?? {}; chatFiles = chatContent?.files ?? []; diff --git a/src/lib/components/chat/Settings/Interface.svelte b/src/lib/components/chat/Settings/Interface.svelte index 632602d22e..80942a09eb 100644 --- a/src/lib/components/chat/Settings/Interface.svelte +++ b/src/lib/components/chat/Settings/Interface.svelte @@ -5,19 +5,14 @@ import Tooltip from '$lib/components/common/Tooltip.svelte'; import { updateUserInfo } from '$lib/apis/users'; import { getUserPosition } from '$lib/utils'; + import { setTextScale } from '$lib/utils/text-scale'; + import Minus from '$lib/components/icons/Minus.svelte'; import Plus from '$lib/components/icons/Plus.svelte'; import Switch from '$lib/components/common/Switch.svelte'; import ManageFloatingActionButtonsModal from './Interface/ManageFloatingActionButtonsModal.svelte'; import ManageImageCompressionModal from './Interface/ManageImageCompressionModal.svelte'; - import { - DEFAULT_TEXT_SCALE_INDEX, - TEXT_SCALE_MAX, - TEXT_SCALE_MIN, - TEXT_SCALE_VALUES, - findClosestTextScaleIndex, - getScaleFromIndex - } from '$lib/utils/text-scale'; + const dispatch = createEventDispatcher(); const i18n = getContext('i18n'); @@ -105,45 +100,7 @@ let showManageFloatingActionButtonsModal = false; let showManageImageCompressionModal = false; - let textScaleIndex = DEFAULT_TEXT_SCALE_INDEX; - let unsubscribeTextScale: (() => void) | undefined; - - const persistTextScale = () => { - const scale = getScaleFromIndex(textScaleIndex); - - if ($settings?.textScale === scale) { - return; - } - - saveSettings({ textScale: scale }); - }; - - const decreaseTextScale = () => { - const previous = textScaleIndex; - textScaleIndex = Math.max(0, textScaleIndex - 1); - - if (textScaleIndex === previous) { - return; - } - - persistTextScale(); - }; - - const increaseTextScale = () => { - const previous = textScaleIndex; - textScaleIndex = Math.min(TEXT_SCALE_VALUES.length - 1, textScaleIndex + 1); - - if (textScaleIndex === previous) { - return; - } - - persistTextScale(); - }; - - $: currentTextScale = getScaleFromIndex(textScaleIndex); - $: textScaleDisplay = Number.isInteger(currentTextScale) - ? `${currentTextScale.toFixed(0)}` - : `${currentTextScale.toFixed(1)}`; + let textScale = null; const toggleLandingPageMode = async () => { landingPageMode = landingPageMode === '' ? 'chat' : ''; @@ -227,6 +184,12 @@ saveSettings({ webSearch: webSearch }); }; + const setTextScaleHandler = (scale) => { + textScale = scale; + setTextScale(textScale); + saveSettings({ textScale }); + }; + onMount(async () => { titleAutoGenerate = $settings?.title?.auto ?? true; autoTags = $settings?.autoTags ?? true; @@ -301,19 +264,7 @@ backgroundImageUrl = $settings?.backgroundImageUrl ?? null; webSearch = $settings?.webSearch ?? null; - textScaleIndex = findClosestTextScaleIndex($settings?.textScale ?? 1); - - unsubscribeTextScale = settings.subscribe((uiSettings) => { - const nextScaleIndex = findClosestTextScaleIndex(uiSettings?.textScale ?? 1); - - if (nextScaleIndex !== textScaleIndex) { - textScaleIndex = nextScaleIndex; - } - }); - }); - - onDestroy(() => { - unsubscribeTextScale?.(); + textScale = $settings?.textScale ?? null; }); @@ -382,7 +333,7 @@
- {textScaleDisplay}x + {textScale}x
@@ -390,7 +341,10 @@