Persist log and connection search state across tabs
This commit is contained in:
@@ -15,15 +15,16 @@ public struct LogView: View {
|
||||
public init() {}
|
||||
|
||||
public var body: some View {
|
||||
LogViewContent(commandClient: environments.commandClient)
|
||||
LogViewContent(commandClient: environments.commandClient, initialSearchText: environments.logSearchText)
|
||||
}
|
||||
}
|
||||
|
||||
private struct LogViewContent: View {
|
||||
@EnvironmentObject private var environments: ExtensionEnvironments
|
||||
@StateObject private var viewModel: LogViewModel
|
||||
|
||||
init(commandClient: CommandClient) {
|
||||
_viewModel = StateObject(wrappedValue: LogViewModel(commandClient: commandClient))
|
||||
init(commandClient: CommandClient, initialSearchText: String = "") {
|
||||
_viewModel = StateObject(wrappedValue: LogViewModel(commandClient: commandClient, searchText: initialSearchText))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -35,6 +36,9 @@ private struct LogViewContent: View {
|
||||
toolbarButtons
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
environments.logSearchText = viewModel.searchText
|
||||
}
|
||||
.alert($viewModel.alert)
|
||||
.background(
|
||||
LogExportView(
|
||||
|
||||
Reference in New Issue
Block a user