mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-25 17:15:19 +08:00
fix: tables cannot be selected when there is no conversation (#98)
This commit is contained in:
@ -40,6 +40,9 @@ const ConnectionSidebar = () => {
|
|||||||
conversationStore.currentConversationId
|
conversationStore.currentConversationId
|
||||||
)?.selectedTablesName || [];
|
)?.selectedTablesName || [];
|
||||||
const tableSchemaLoadingState = useLoading();
|
const tableSchemaLoadingState = useLoading();
|
||||||
|
const currentConversation = conversationStore.getConversationById(
|
||||||
|
conversationStore.currentConversationId
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleWindowResize = () => {
|
const handleWindowResize = () => {
|
||||||
@ -118,17 +121,36 @@ const ConnectionSidebar = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// only create conversation when currentConversation is null.
|
||||||
|
// Note: This function is used to solve issue #95
|
||||||
|
// https://github.com/sqlchat/sqlchat/issues/95
|
||||||
|
const createConversation = () => {
|
||||||
|
if (!currentConversation) {
|
||||||
|
if (!currentConnectionCtx) {
|
||||||
|
conversationStore.createConversation();
|
||||||
|
} else {
|
||||||
|
conversationStore.createConversation(
|
||||||
|
currentConnectionCtx.connection.id,
|
||||||
|
currentConnectionCtx.database?.name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleTableNameSelect = async (selectedTablesName: string[]) => {
|
const handleTableNameSelect = async (selectedTablesName: string[]) => {
|
||||||
|
createConversation();
|
||||||
conversationStore.updateSelectedTablesName(selectedTablesName);
|
conversationStore.updateSelectedTablesName(selectedTablesName);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAllSelect = async () => {
|
const handleAllSelect = async () => {
|
||||||
|
createConversation();
|
||||||
conversationStore.updateSelectedTablesName(
|
conversationStore.updateSelectedTablesName(
|
||||||
tableList.map((table) => table.name)
|
tableList.map((table) => table.name)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEmptySelect = async () => {
|
const handleEmptySelect = async () => {
|
||||||
|
createConversation();
|
||||||
conversationStore.updateSelectedTablesName([]);
|
conversationStore.updateSelectedTablesName([]);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user