mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-26 01:23:18 +08:00
fix: missing database in connection context
This commit is contained in:
@ -68,6 +68,7 @@ const ConnectionSidebar = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleConnectionSelect = async (connection: Connection) => {
|
const handleConnectionSelect = async (connection: Connection) => {
|
||||||
|
const databaseList = await connectionStore.getOrFetchDatabaseList(connection);
|
||||||
connectionStore.setCurrentConnectionCtx({
|
connectionStore.setCurrentConnectionCtx({
|
||||||
connection,
|
connection,
|
||||||
database: head(databaseList),
|
database: head(databaseList),
|
||||||
@ -87,6 +88,7 @@ const ConnectionSidebar = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const databaseList = await connectionStore.getOrFetchDatabaseList(currentConnectionCtx.connection);
|
||||||
const database = databaseList.find((database) => database.name === databaseName);
|
const database = databaseList.find((database) => database.name === databaseName);
|
||||||
connectionStore.setCurrentConnectionCtx({
|
connectionStore.setCurrentConnectionCtx({
|
||||||
connection: currentConnectionCtx.connection,
|
connection: currentConnectionCtx.connection,
|
||||||
|
@ -76,7 +76,7 @@ export const useConnectionStore = create<ConnectionState>()(
|
|||||||
} as Database)
|
} as Database)
|
||||||
);
|
);
|
||||||
const databaseList = uniqBy(
|
const databaseList = uniqBy(
|
||||||
[...state.databaseList, ...fetchedDatabaseList],
|
[...fetchedDatabaseList, ...state.databaseList],
|
||||||
(database) => `${database.connectionId}_${database.name}`
|
(database) => `${database.connectionId}_${database.name}`
|
||||||
);
|
);
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
|
Reference in New Issue
Block a user