forked from open-webui/open-webui
fix: delete current chat issue
This commit is contained in:
parent
4294ec6db8
commit
3f8b1d2506
1 changed files with 7 additions and 2 deletions
|
@ -1,14 +1,15 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { openDB, deleteDB } from 'idb';
|
import { openDB, deleteDB } from 'idb';
|
||||||
import { onMount, tick } from 'svelte';
|
import { onMount, tick } from 'svelte';
|
||||||
import { goto } from '$app/navigation';
|
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 SettingsModal from '$lib/components/chat/SettingsModal.svelte';
|
||||||
import Sidebar from '$lib/components/layout/Sidebar.svelte';
|
import Sidebar from '$lib/components/layout/Sidebar.svelte';
|
||||||
import toast from 'svelte-french-toast';
|
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;
|
let loaded = false;
|
||||||
|
|
||||||
|
@ -133,6 +134,10 @@
|
||||||
await chats.set(await this.getChats());
|
await chats.set(await this.getChats());
|
||||||
},
|
},
|
||||||
deleteChatById: async function (id) {
|
deleteChatById: async function (id) {
|
||||||
|
if ($chatId === id) {
|
||||||
|
goto('/');
|
||||||
|
await chatId.set(uuidv4());
|
||||||
|
}
|
||||||
await this.db.delete('chats', id);
|
await this.db.delete('chats', id);
|
||||||
await chats.set(await this.getChats());
|
await chats.set(await this.getChats());
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue