diff --git a/components/ConnectionSidebar.tsx b/components/ConnectionSidebar.tsx index e77db74..ad6bb2b 100644 --- a/components/ConnectionSidebar.tsx +++ b/components/ConnectionSidebar.tsx @@ -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, diff --git a/store/connection.ts b/store/connection.ts index f5e5936..2f9d25b 100644 --- a/store/connection.ts +++ b/store/connection.ts @@ -76,7 +76,7 @@ export const useConnectionStore = create()( } as Database) ); const databaseList = uniqBy( - [...state.databaseList, ...fetchedDatabaseList], + [...fetchedDatabaseList, ...state.databaseList], (database) => `${database.connectionId}_${database.name}` ); set((state) => ({