Просмотр исходного кода

Merge pull request #18911 from silentoplayz/fix-chat-preview-bug

fix: correct chat preview loading in chats search modal
Tim Baek 3 месяцев назад
Родитель
Сommit
1aa285edb9
1 измененных файлов с 5 добавлено и 7 удалено
  1. 5 7
      src/lib/components/layout/SearchModal.svelte

+ 5 - 7
src/lib/components/layout/SearchModal.svelte

@@ -56,12 +56,7 @@
 	}
 
 	const loadChatPreview = async (selectedIdx) => {
-		if (
-			!chatList ||
-			chatList.length === 0 ||
-			selectedIdx === null ||
-			chatList[selectedIdx] === undefined
-		) {
+		if (!chatList || chatList.length === 0 || selectedIdx === null) {
 			selectedChat = null;
 			messages = null;
 			history = null;
@@ -70,8 +65,11 @@
 		}
 
 		const selectedChatIdx = selectedIdx - actions.length;
-		if (selectedChatIdx < 0) {
+		if (selectedChatIdx < 0 || selectedChatIdx >= chatList.length) {
 			selectedChat = null;
+			messages = null;
+			history = null;
+			selectedModels = [''];
 			return;
 		}