git.iko.soy/parseable-macos
on master help sign in
Fix query text not clearing when switching streams after opening saved filter (#46)
d1db137iko
ParseableViewer/ViewModels/QueryViewModel.swift+4−6
@@ -536,14 +536,12 @@ final class QueryViewModel {
536 /// query text was replaced (i.e. the user hadn't customized it).
536 /// query text was replaced (i.e. the user hadn't customized it).
537 @discardableResult
537 @discardableResult
538 func setDefaultQuery(stream: String, previousStream: String? = nil) -> Bool {
538 func setDefaultQuery(stream: String, previousStream: String? = nil) -> Bool {
539− // Replace the query if it's empty or still matches the auto-generated
539+ // Always replace when switching streams — the previous query (whether
540− // default for the previous stream. If the user edited the SQL, keep it.
540+ // auto-generated or from a saved filter) belongs to the old stream.
541+ // Only preserve the query when no stream change occurred (e.g. onAppear).
541 let shouldReplace: Bool
542 let shouldReplace: Bool
542− if sqlQuery.isEmpty {
543+ if sqlQuery.isEmpty || previousStream != nil {
543 shouldReplace = true
544 shouldReplace = true
544− } else if let prev = previousStream {
545− let prevPrefix = "SELECT * FROM \(Self.escapeSQLIdentifier(prev))"
546− shouldReplace = sqlQuery.hasPrefix(prevPrefix)
547 } else {
545 } else {
548 shouldReplace = false
546 shouldReplace = false
549 }
547 }