Skip to content

Commit 5257ec3

Browse files
committed
fix: persist switched database name in session — show correct title on reconnect
1 parent 7b78036 commit 5257ec3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

TableProMobile/TableProMobile/Views/ConnectedView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ struct ConnectedView: View {
264264
guard let session, supportsDatabaseSwitching else { return }
265265
do {
266266
databases = try await session.driver.fetchDatabases()
267-
activeDatabase = connection.database
267+
// Use session's active database (may differ from connection.database after a switch)
268+
if let stored = appState.connectionManager.session(for: connection.id) {
269+
activeDatabase = stored.activeDatabase
270+
} else {
271+
activeDatabase = connection.database
272+
}
268273
} catch {
269274
// Silently fail — just don't show picker
270275
}
@@ -303,7 +308,7 @@ struct ConnectedView: View {
303308
await reconnectWithDatabase(name)
304309
} else {
305310
do {
306-
try await session.driver.switchDatabase(to: name)
311+
try await appState.connectionManager.switchDatabase(connection.id, to: name)
307312
activeDatabase = name
308313
self.tables = try await session.driver.fetchTables(schema: nil)
309314
} catch {

0 commit comments

Comments
 (0)