"vscode:/vscode.git/clone" did not exist on "b294221da0b6cec5eb71145cc6d02b49b5de6150"
Commit 4d375498 authored by Anuraag Jain's avatar Anuraag Jain
Browse files

fix(model-selector): prevent saving empty default model

- throw a toast error when user is trying to click on `set as default` without actually choosing the model(s).
- feat: added hmr for local development. use `npm run dev` and you get the hmr when debugging.
parent 72524272
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
export let disabled = false; export let disabled = false;
const saveDefaultModel = () => { const saveDefaultModel = () => {
const hasEmptyModel = selectedModels.filter(it => it === '');
if(hasEmptyModel.length){
toast.error('Choose a model before saving...');
return;
}
settings.set({ ...$settings, models: selectedModels }); settings.set({ ...$settings, models: selectedModels });
localStorage.setItem('settings', JSON.stringify($settings)); localStorage.setItem('settings', JSON.stringify($settings));
toast.success('Default model updated'); toast.success('Default model updated');
...@@ -21,7 +26,7 @@ ...@@ -21,7 +26,7 @@
bind:value={selectedModel} bind:value={selectedModel}
{disabled} {disabled}
> >
<option class=" text-gray-700" value="" selected>Select a model</option> <option class=" text-gray-700" value="" selected disabled>Select a model</option>
{#each $models as model} {#each $models as model}
{#if model.name === 'hr'} {#if model.name === 'hr'}
......
...@@ -2,5 +2,8 @@ import { sveltekit } from '@sveltejs/kit/vite'; ...@@ -2,5 +2,8 @@ import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
plugins: [sveltekit()] plugins: [sveltekit()],
server: {
hmr: true
}
}); });
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment