From 7001170a27d027e57696f3b4d2346c14656ee96c Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 28 Mar 2023 11:45:52 +0800 Subject: [PATCH] chore: add default channel --- components/ChatView/index.tsx | 8 +++++++- components/ConnectionSidebar.tsx | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 = () => {
+ {connectionList.map((connection) => (