chore: add default channel

This commit is contained in:
steven
2023-03-28 11:45:52 +08:00
parent a41f42b32b
commit 7001170a27
2 changed files with 13 additions and 1 deletions

View File

@ -59,12 +59,18 @@ const ChatView = () => {
useEffect(() => { useEffect(() => {
if (!connectionStore.currentConnectionCtx) { if (!connectionStore.currentConnectionCtx) {
chatStore.setCurrentChat(undefined);
return; return;
} }
if (currentChat?.connectionId === connectionStore.currentConnectionCtx.connection.id) { if (currentChat?.connectionId === connectionStore.currentConnectionCtx.connection.id) {
chatStore.setCurrentChat(undefined);
return; 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)); chatStore.setCurrentChat(head(chatList));
}, [connectionStore.currentConnectionCtx]); }, [connectionStore.currentConnectionCtx]);

View File

@ -117,6 +117,12 @@ const ConnectionSidebar = () => {
<div className="w-80 h-full border-r flex flex-row justify-start items-start"> <div className="w-80 h-full border-r flex flex-row justify-start items-start">
<div className="w-16 h-full bg-gray-200 pl-2 py-4 pt-6 flex flex-col justify-between items-center"> <div className="w-16 h-full bg-gray-200 pl-2 py-4 pt-6 flex flex-col justify-between items-center">
<div className="w-full flex flex-col justify-start items-start"> <div className="w-full flex flex-col justify-start items-start">
<button
className={`w-full h-14 rounded-l-lg p-2 mt-2 group ${currentConnectionCtx === undefined && "bg-gray-100 shadow"}`}
onClick={() => connectionStore.setCurrentConnectionCtx(undefined)}
>
<Icon.AiOutlineRobot className="w-7 h-auto mx-auto" />
</button>
{connectionList.map((connection) => ( {connectionList.map((connection) => (
<button <button
key={connection.id} key={connection.id}