Skip to content

Commit f0ca66e

Browse files
committed
fix: show loading spinner instead of empty state while sidebar tables load
1 parent 4dd51c0 commit f0ca66e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

TablePro/ViewModels/SidebarViewModel.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,11 @@ final class SidebarViewModel {
158158
NSLog("[SidebarVM] onAppear: tables not empty (%d), skipping", tables.count)
159159
return
160160
}
161-
Task { @MainActor in
162-
if DatabaseManager.shared.driver(for: connectionId) != nil {
163-
NSLog("[SidebarVM] onAppear: driver found, loading tables")
164-
loadTables()
165-
} else {
166-
NSLog("[SidebarVM] onAppear: driver is nil for %@", connectionId.uuidString)
167-
}
161+
if DatabaseManager.shared.driver(for: connectionId) != nil {
162+
NSLog("[SidebarVM] onAppear: driver found, loading tables")
163+
loadTables()
164+
} else {
165+
NSLog("[SidebarVM] onAppear: driver is nil for %@", connectionId.uuidString)
168166
}
169167
}
170168

TablePro/Views/Sidebar/SidebarView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct SidebarView: View {
149149
private var tablesContent: some View {
150150
if let error = viewModel.errorMessage {
151151
errorState(message: error)
152-
} else if tables.isEmpty && viewModel.isLoading {
152+
} else if tables.isEmpty && hasActiveConnection {
153153
loadingState
154154
} else if tables.isEmpty {
155155
emptyState
@@ -158,6 +158,10 @@ struct SidebarView: View {
158158
}
159159
}
160160

161+
private var hasActiveConnection: Bool {
162+
viewModel.isLoading || DatabaseManager.shared.driver(for: connectionId) != nil
163+
}
164+
161165
private var loadingState: some View {
162166
ProgressView()
163167
.frame(maxWidth: .infinity, maxHeight: .infinity)

0 commit comments

Comments
 (0)