Forráskód Böngészése

fix: delete current chat issue

Timothy J. Baek 1 éve
szülő
commit
3f8b1d2506
1 módosított fájl, 7 hozzáadás és 2 törlés
  1. 7 2
      src/routes/(app)/+layout.svelte

+ 7 - 2
src/routes/(app)/+layout.svelte

@@ -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());
 			},