mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-08 03:08:02 +00:00
refac
This commit is contained in:
parent
016928722c
commit
af4500e504
1 changed files with 19 additions and 0 deletions
|
|
@ -37,6 +37,20 @@
|
|||
|
||||
let unsubscribeSettings;
|
||||
|
||||
const cleanupStalePinnedModels = async (modelIds) => {
|
||||
const validModels = modelIds.filter((id) => {
|
||||
const model = $models.find((m) => m.id === id);
|
||||
// Remove if model not found (deleted) or if hidden
|
||||
return model && !(model?.info?.meta?.hidden ?? false);
|
||||
});
|
||||
|
||||
if (validModels.length !== modelIds.length) {
|
||||
pinnedModels = validModels;
|
||||
settings.set({ ...$settings, pinnedModels: validModels });
|
||||
await updateUserSettings(localStorage.token, { ui: $settings });
|
||||
}
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
pinnedModels = $settings?.pinnedModels ?? [];
|
||||
|
||||
|
|
@ -48,6 +62,11 @@
|
|||
await updateUserSettings(localStorage.token, { ui: $settings });
|
||||
}
|
||||
|
||||
// Auto-unpin hidden or deleted models
|
||||
if (pinnedModels.length > 0) {
|
||||
await cleanupStalePinnedModels(pinnedModels);
|
||||
}
|
||||
|
||||
unsubscribeSettings = settings.subscribe((value) => {
|
||||
pinnedModels = value?.pinnedModels ?? [];
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue