refac
This commit is contained in:
@@ -37,6 +37,20 @@
|
|||||||
|
|
||||||
let unsubscribeSettings;
|
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 () => {
|
onMount(async () => {
|
||||||
pinnedModels = $settings?.pinnedModels ?? [];
|
pinnedModels = $settings?.pinnedModels ?? [];
|
||||||
|
|
||||||
@@ -48,6 +62,11 @@
|
|||||||
await updateUserSettings(localStorage.token, { ui: $settings });
|
await updateUserSettings(localStorage.token, { ui: $settings });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-unpin hidden or deleted models
|
||||||
|
if (pinnedModels.length > 0) {
|
||||||
|
await cleanupStalePinnedModels(pinnedModels);
|
||||||
|
}
|
||||||
|
|
||||||
unsubscribeSettings = settings.subscribe((value) => {
|
unsubscribeSettings = settings.subscribe((value) => {
|
||||||
pinnedModels = value?.pinnedModels ?? [];
|
pinnedModels = value?.pinnedModels ?? [];
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user