git.iko.soy/parseable-macos
on master help sign in
Clear logs when switching datasets (#5)
edca1aeiko
ParseableViewer/ViewModels/QueryViewModel.swift+10
@@ -274,6 +274,16 @@ final class QueryViewModel {
274 return value
274 return value
275 }
275 }
276
276
277+ func clearResults() {
278+ results = []
279+ columns = []
280+ resultCount = 0
281+ queryDuration = nil
282+ selectedLogEntry = nil
283+ errorMessage = nil
284+ resultsTruncated = false
285+ }
286+
277 func setDefaultQuery(stream: String, previousStream: String? = nil) {
287 func setDefaultQuery(stream: String, previousStream: String? = nil) {
278 // Replace the query if it's empty or still matches the auto-generated
288 // Replace the query if it's empty or still matches the auto-generated
279 // default for the previous stream. If the user edited the SQL, keep it.
289 // default for the previous stream. If the user edited the SQL, keep it.
ParseableViewer/Views/LiveTailView.swift+1
@@ -173,6 +173,7 @@ struct LiveTailView: View {
173 if viewModel.isRunning {
173 if viewModel.isRunning {
174 viewModel.stop()
174 viewModel.stop()
175 }
175 }
176+ viewModel.clear()
176 }
177 }
177 }
178 }
178}
179}
ParseableViewer/Views/QueryView.swift+1
@@ -195,6 +195,7 @@ struct QueryView: View {
195 }
195 }
196 }
196 }
197 .onChange(of: appState.selectedStream) { oldValue, newValue in
197 .onChange(of: appState.selectedStream) { oldValue, newValue in
198+ viewModel.clearResults()
198 if let stream = newValue {
199 if let stream = newValue {
199 viewModel.setDefaultQuery(stream: stream, previousStream: oldValue)
200 viewModel.setDefaultQuery(stream: stream, previousStream: oldValue)
200 }
201 }