diff --git a/components/ChatView/index.tsx b/components/ChatView/index.tsx index 950823d..afc6acd 100644 --- a/components/ChatView/index.tsx +++ b/components/ChatView/index.tsx @@ -59,12 +59,18 @@ const ChatView = () => { useEffect(() => { if (!connectionStore.currentConnectionCtx) { + chatStore.setCurrentChat(undefined); return; } if (currentChat?.connectionId === connectionStore.currentConnectionCtx.connection.id) { + chatStore.setCurrentChat(undefined); return; } - const chatList = chatStore.chatList.filter((chat) => chat.connectionId === connectionStore.currentConnectionCtx?.connection.id); + const chatList = chatStore.chatList.filter( + (chat) => + chat.connectionId === connectionStore.currentConnectionCtx?.connection.id && + chat.databaseName === connectionStore.currentConnectionCtx?.database?.name + ); chatStore.setCurrentChat(head(chatList)); }, [connectionStore.currentConnectionCtx]); diff --git a/components/ConnectionSidebar.tsx b/components/ConnectionSidebar.tsx index 898ca86..7992055 100644 --- a/components/ConnectionSidebar.tsx +++ b/components/ConnectionSidebar.tsx @@ -117,6 +117,12 @@ const ConnectionSidebar = () => {