| 125 | }, [schemaList, currentConversation]); |
| 126 | |
| 127 | const syncDatabaseList = async () => { |
| 128 | if (!currentConnectionCtx?.connection) { |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | const prevDatabase = currentConnectionCtx.database; |
| 133 | const databaseList = await connectionStore.getOrFetchDatabaseList(currentConnectionCtx.connection, true); |
| 134 | |
| 135 | // Retain the existing database if it exists in the new database list. |
| 136 | const database = databaseList.find((database) => database.name === prevDatabase?.name); |
| 137 | connectionStore.setCurrentConnectionCtx({ |
| 138 | connection: currentConnectionCtx.connection, |
| 139 | database: database ? database : head(databaseList), |
| 140 | }); |
| 141 | if (database) { |
| 142 | tableSchemaLoadingState.setLoading(); |
| 143 | connectionStore.getOrFetchDatabaseSchema(database).then(() => { |
| 144 | tableSchemaLoadingState.setFinish(); |
| 145 | }); |
| 146 | } |
| 147 | }; |
| 148 | |
| 149 | const handleDatabaseNameSelect = async (databaseName: string) => { |
| 150 | if (!currentConnectionCtx?.connection) { |