Skip to content
Snippets Groups Projects
Commit ba81dc8e authored by Leonardo Christino's avatar Leonardo Christino
Browse files

feat(fix): new database connect

properly connect to recently added database
parent 4de71777
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@ export const sessionSlice = createSlice({
initialState,
reducers: {
updateCurrentDatabase(state, action: PayloadAction<string>) {
console.log('Updating current database', state.currentDatabase, action.payload);
state.currentDatabase = action.payload;
},
updateDatabaseList(state, action: PayloadAction<DatabaseInfo[]>) {
......@@ -34,10 +36,12 @@ export const sessionSlice = createSlice({
state.databases = action.payload;
if (state.databases.length > 0) {
const foundDatabase = state.databases.find((db) => db.Name === state.currentDatabase);
console.log(foundDatabase);
if (!foundDatabase) {
state.currentDatabase = state.databases[0].Name;
} else {
state.currentDatabase = undefined;
state.currentDatabase = foundDatabase?.Name || undefined;
}
}
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment