Skip to content

Commit 3d956f3

Browse files
authored
fix: remove redundant async dispatch in RightPanelState, guard switchDatabase result (#535)
1 parent 595595f commit 3d956f3

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

TablePro/Core/Database/DatabaseManager.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ final class DatabaseManager {
184184
if resolvedConnection.database.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty,
185185
let adapter = driver as? PluginDriverAdapter,
186186
let savedDb = AppSettingsStorage.shared.loadLastDatabase(for: connection.id) {
187-
try? await adapter.switchDatabase(to: savedDb)
188-
activeSessions[connection.id]?.currentDatabase = savedDb
187+
do {
188+
try await adapter.switchDatabase(to: savedDb)
189+
activeSessions[connection.id]?.currentDatabase = savedDb
190+
} catch {
191+
Self.logger.warning("Failed to restore saved database '\(savedDb, privacy: .public)' for \(connection.id): \(error.localizedDescription, privacy: .public)")
192+
}
189193
}
190194
case .selectDatabaseFromConnectionField(let fieldId):
191195
// Select database from a connection field (e.g. Redis database index).

TablePro/Models/UI/RightPanelState.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ import os
2424
var isPresented: Bool {
2525
didSet {
2626
guard !isSyncing else { return }
27-
DispatchQueue.main.async { [self] in
28-
UserDefaults.standard.set(self.isPresented, forKey: Self.isPresentedKey)
29-
NotificationCenter.default.post(name: Self.isPresentedChangedNotification, object: self)
30-
}
27+
UserDefaults.standard.set(isPresented, forKey: Self.isPresentedKey)
28+
NotificationCenter.default.post(name: Self.isPresentedChangedNotification, object: self)
3129
}
3230
}
3331

0 commit comments

Comments
 (0)