fix: sidebar model selector issue

This commit is contained in:
Timothy J. Baek
2024-05-14 12:26:53 -10:00
parent ad67339426
commit de75679ffb
4 changed files with 24 additions and 4 deletions
+18 -1
View File
@@ -1,6 +1,6 @@
<script>
import { onMount, tick, setContext } from 'svelte';
import { config, user, theme, WEBUI_NAME } from '$lib/stores';
import { config, user, theme, WEBUI_NAME, mobile } from '$lib/stores';
import { goto } from '$app/navigation';
import { Toaster, toast } from 'svelte-sonner';
@@ -18,9 +18,22 @@
setContext('i18n', i18n);
let loaded = false;
const BREAKPOINT = 1024;
onMount(async () => {
theme.set(localStorage.theme);
mobile.set(window.innerWidth < BREAKPOINT);
const onResize = () => {
if (window.innerWidth < BREAKPOINT) {
mobile.set(true);
} else {
mobile.set(false);
}
};
window.addEventListener('resize', onResize);
let backendConfig = null;
try {
backendConfig = await getBackendConfig();
@@ -67,6 +80,10 @@
document.getElementById('splash-screen')?.remove();
loaded = true;
return () => {
window.removeEventListener('resize', onResize);
};
});
</script>