fix: delete current chat issue

This commit is contained in:
Timothy J. Baek 2023-11-24 21:41:56 -08:00
parent 4294ec6db8
commit 3f8b1d2506

View file

@ -1,14 +1,15 @@
<script lang="ts">
import { v4 as uuidv4 } from 'uuid';
import { openDB, deleteDB } from 'idb';
import { onMount, tick } from 'svelte';
import { goto } from '$app/navigation';
import { config, user, showSettings, settings, models, db, chats } from '$lib/stores';
import { config, user, showSettings, settings, models, db, chats, chatId } from '$lib/stores';
import SettingsModal from '$lib/components/chat/SettingsModal.svelte';
import Sidebar from '$lib/components/layout/Sidebar.svelte';
import toast from 'svelte-french-toast';
import { OLLAMA_API_BASE_URL } from '$lib/constants';
import { OLLAMA_API_BASE_URL, WEBUI_API_BASE_URL } from '$lib/constants';
let loaded = false;
@ -133,6 +134,10 @@
await chats.set(await this.getChats());
},
deleteChatById: async function (id) {
if ($chatId === id) {
goto('/');
await chatId.set(uuidv4());
}
await this.db.delete('chats', id);
await chats.set(await this.getChats());
},