fix(ui): deduplicate store fetches with null-guards and mutex (#25943)

This commit is contained in:
G30 authored and GitHub committed 2026-06-17 00:07:11 +02:00
1 parent 22f2fe1ffb
commit ee3a49a88d
6 files changed
+19 -20

No files matched your search

@@ -150,7 +150,8 @@
selectedTab = 'overview'; selectedTab = 'overview';
chatList = []; chatList = [];
allChatsLoaded = false; allChatsLoaded = false;
selectRange(selectedRange); selectedRange = '30d';
loadOverview(30);
} }
</script> </script>
@@ -51,7 +51,8 @@
// Load history when model changes and modal is shown // Load history when model changes and modal is shown
$: if (show && model?.id) { $: if (show && model?.id) {
selectRange(selectedRange); selectedRange = '30d';
loadHistory(30);
} }
// Use top_tags from backend response (already computed) // Use top_tags from backend response (already computed)
@@ -117,10 +117,6 @@
.map((c) => ({ type: 'channel', id: c.id, label: c.name, data: c })) .map((c) => ({ type: 'channel', id: c.id, label: c.name, data: c }))
]; ];
} else { } else {
if (userSuggestions) {
getUserList();
}
if (modelSuggestions) { if (modelSuggestions) {
_models = [ _models = [
...$models ...$models
+11 -9
View File
@@ -113,7 +113,6 @@
import Tooltip from '../common/Tooltip.svelte'; import Tooltip from '../common/Tooltip.svelte';
import Sidebar from '../icons/Sidebar.svelte'; import Sidebar from '../icons/Sidebar.svelte';
import Image from '../common/Image.svelte'; import Image from '../common/Image.svelte';
import { getBanners } from '$lib/apis/configs';
export let chatIdProp = ''; export let chatIdProp = '';
@@ -330,7 +329,12 @@
); );
}; };
let settingDefaults = false;
const setDefaults = async () => { const setDefaults = async () => {
if (settingDefaults) return;
settingDefaults = true;
try {
if (!$tools) { if (!$tools) {
tools.set(await getTools(localStorage.token)); tools.set(await getTools(localStorage.token));
} }
@@ -350,7 +354,9 @@
if (model?.info?.meta?.toolIds) { if (model?.info?.meta?.toolIds) {
const defaultIds = [ const defaultIds = [
...new Set( ...new Set(
[...(model?.info?.meta?.toolIds ?? [])].filter((id) => $tools.find((t) => t.id === id)) [...(model?.info?.meta?.toolIds ?? [])].filter((id) =>
$tools.find((t) => t.id === id)
)
) )
]; ];
@@ -432,6 +438,9 @@
} }
} }
} }
} finally {
settingDefaults = false;
}
}; };
const showMessage = async (message, scroll = true) => { const showMessage = async (message, scroll = true) => {
@@ -796,13 +805,6 @@
if (p.url.pathname === '/') { if (p.url.pathname === '/') {
await tick(); await tick();
initNewChat(); initNewChat();
// Re-fetch banners on navigation to homepage so newly configured banners appear
try {
banners.set(await getBanners(localStorage.token).catch(() => []));
} catch (e) {
console.error('Failed to refresh banners:', e);
}
} }
stopAudio(); stopAudio();
@@ -58,8 +58,6 @@
import { deleteFileById } from '$lib/apis/files'; import { deleteFileById } from '$lib/apis/files';
import { getChatById } from '$lib/apis/chats'; import { getChatById } from '$lib/apis/chats';
import { getSessionUser } from '$lib/apis/auths'; import { getSessionUser } from '$lib/apis/auths';
import { getTools } from '$lib/apis/tools';
import { getSkills } from '$lib/apis/skills';
import { WEBUI_BASE_URL, WEBUI_API_BASE_URL, PASTED_TEXT_CHARACTER_LIMIT } from '$lib/constants'; import { WEBUI_BASE_URL, WEBUI_API_BASE_URL, PASTED_TEXT_CHARACTER_LIMIT } from '$lib/constants';
import { getOAuthClientAuthorizationUrl } from '$lib/apis/configs'; import { getOAuthClientAuthorizationUrl } from '$lib/apis/configs';
@@ -1106,9 +1104,6 @@
dropzoneElement.addEventListener('drop', onDrop, true); dropzoneElement.addEventListener('drop', onDrop, true);
dropzoneElement.addEventListener('dragleave', onDragLeave); dropzoneElement.addEventListener('dragleave', onDragLeave);
} }
tools.set(await getTools(localStorage.token));
skills.set(await getSkills(localStorage.token));
}; };
initialize(); initialize();
@@ -248,9 +248,13 @@
}; };
onMount(async () => { onMount(async () => {
if (!$tools) {
await tools.set(await getTools(localStorage.token)); await tools.set(await getTools(localStorage.token));
}
skillsList = (await getSkills(localStorage.token).catch(() => null)) ?? []; skillsList = (await getSkills(localStorage.token).catch(() => null)) ?? [];
if (!$functions) {
await functions.set(await getFunctions(localStorage.token)); await functions.set(await getFunctions(localStorage.token));
}
// Fetch admin-configured default model metadata so the editor // Fetch admin-configured default model metadata so the editor
// reflects the actual defaults rather than hardcoded values // reflects the actual defaults rather than hardcoded values