mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-25 09:03:43 +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 databaseList = await connectionStore.getOrFetchDatabaseList(connection);
|
||||
connectionStore.setCurrentConnectionCtx({
|
||||
connection,
|
||||
database: head(databaseList),
|
||||
@ -87,6 +88,7 @@ const ConnectionSidebar = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const databaseList = await connectionStore.getOrFetchDatabaseList(currentConnectionCtx.connection);
|
||||
const database = databaseList.find((database) => database.name === databaseName);
|
||||
connectionStore.setCurrentConnectionCtx({
|
||||
connection: currentConnectionCtx.connection,
|
||||
|
@ -76,7 +76,7 @@ export const useConnectionStore = create<ConnectionState>()(
|
||||
} as Database)
|
||||
);
|
||||
const databaseList = uniqBy(
|
||||
[...state.databaseList, ...fetchedDatabaseList],
|
||||
[...fetchedDatabaseList, ...state.databaseList],
|
||||
(database) => `${database.connectionId}_${database.name}`
|
||||
);
|
||||
set((state) => ({
|
||||
|
Reference in New Issue
Block a user