Timothy Jaeryang Baek 2 months ago
parent
commit
6f55679a8a
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/lib/components/layout/Sidebar/ChatItem.svelte

+ 9 - 1
src/lib/components/layout/Sidebar/ChatItem.svelte

@@ -25,7 +25,8 @@
 		pinnedChats,
 		showSidebar,
 		currentChatPage,
-		tags
+		tags,
+		selectedFolder
 	} from '$lib/stores';
 
 	import ChatMenu from './ChatMenu.svelte';
@@ -355,6 +356,13 @@
 			on:click={() => {
 				dispatch('select');
 
+				if (
+					$selectedFolder &&
+					!($selectedFolder?.items?.chats.map((chat) => chat.id) ?? []).includes(id)
+				) {
+					selectedFolder.set(null); // Reset selected folder if the chat is not in it
+				}
+
 				if ($mobile) {
 					showSidebar.set(false);
 				}