(model: { providerID: string; modelID: string })
| 337 | }) |
| 338 | }, |
| 339 | toggleFavorite(model: { providerID: string; modelID: string }) { |
| 340 | batch(() => { |
| 341 | if (!isModelValid(model)) { |
| 342 | toast.show({ |
| 343 | message: `Model ${model.providerID}/${model.modelID} is not valid`, |
| 344 | variant: "warning", |
| 345 | duration: 3000, |
| 346 | }) |
| 347 | return |
| 348 | } |
| 349 | const exists = modelStore.favorite.some( |
| 350 | (x) => x.providerID === model.providerID && x.modelID === model.modelID, |
| 351 | ) |
| 352 | const next = exists |
| 353 | ? modelStore.favorite.filter((x) => x.providerID !== model.providerID || x.modelID !== model.modelID) |
| 354 | : [model, ...modelStore.favorite] |
| 355 | setModelStore( |
| 356 | "favorite", |
| 357 | next.map((x) => ({ providerID: x.providerID, modelID: x.modelID })), |
| 358 | ) |
| 359 | save() |
| 360 | }) |
| 361 | }, |
| 362 | variant: { |
| 363 | selected() { |
| 364 | const m = currentModel() |
nothing calls this directly
no test coverage detected