git.iko.soy/parseable-macos
on master help sign in
Fix 3 bugs: stuck loading spinner on connection/stream-switch races
d55225fiko
ParseableViewer/Views/AlertsView.swift+4−2
@@ -85,10 +85,12 @@ struct AlertsView: View {
85 // The manual Refresh/Retry buttons spawn detached Tasks not tied to
85 // The manual Refresh/Retry buttons spawn detached Tasks not tied to
86 // `.task(id: stream)` cancellation, so a slow refresh for the old stream
86 // `.task(id: stream)` cancellation, so a slow refresh for the old stream
87 // can resolve after a switch. Drop stale results.
87 // can resolve after a switch. Drop stale results.
88+ // Still clear isLoading on the stale path: this task set the spinner,
89+ // so leaving it true wedges the ProgressView and disables Refresh.
88− guard stream == appState.selectedStream else { return }
90+ guard stream == appState.selectedStream else { isLoading = false; return }
89 alertConfig = config
91 alertConfig = config
90 } catch {
92 } catch {
91− guard stream == appState.selectedStream else { return }
93+ guard stream == appState.selectedStream else { isLoading = false; return }
92 errorMessage = ParseableError.userFriendlyMessage(for: error)
94 errorMessage = ParseableError.userFriendlyMessage(for: error)
93 }
95 }
94
96
ParseableViewer/Views/ServerInfoView.swift+3−1
@@ -168,7 +168,9 @@ struct ServerInfoView: View {
168
168
169 // Drop results if the active connection changed while awaiting, so a slow
169 // Drop results if the active connection changed while awaiting, so a slow
170 // load for the previous server can't overwrite the current one's state.
170 // load for the previous server can't overwrite the current one's state.
171+ // Still clear isLoading: this task owns the spinner it set, and leaving it
172+ // true on the stale path wedges the ProgressView and disables Refresh.
171− guard connID == appState.activeConnection?.id else { return }
173+ guard connID == appState.activeConnection?.id else { isLoading = false; return }
172 isHealthy = healthy
174 isHealthy = healthy
173 about = aboutValue
175 about = aboutValue
174 errorMessage = aboutError
176 errorMessage = aboutError
ParseableViewer/Views/UsersView.swift+4−2
@@ -95,8 +95,10 @@ struct UsersView: View {
95 loadError = ParseableError.userFriendlyMessage(for: error)
95 loadError = ParseableError.userFriendlyMessage(for: error)
96 }
96 }
97
97
98− // Drop results if the active connection changed while awaiting.
98+ // Drop results if the active connection changed while awaiting. Still clear
99+ // isLoading: this task set the spinner, so leaving it true on the stale path
100+ // wedges the ProgressView and disables Refresh.
99− guard connID == appState.activeConnection?.id else { return }
101+ guard connID == appState.activeConnection?.id else { isLoading = false; return }
100 if let loaded { users = loaded }
102 if let loaded { users = loaded }
101 errorMessage = loadError
103 errorMessage = loadError
102 isLoading = false
104 isLoading = false