From 4fc04abe8ba83af82daf0ec385ed354258743fc9 Mon Sep 17 00:00:00 2001 From: jibedoubleve Date: Thu, 20 Jan 2022 15:45:04 +0100 Subject: [PATCH] Fix #99, Fix #98 - Settings are lost after log refresh --- .../ViewModels/LogsViewModel.cs | 26 ++++++++++--------- src/Probel.LogReader/Views/LogsView.xaml.cs | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Probel.LogReader/ViewModels/LogsViewModel.cs b/src/Probel.LogReader/ViewModels/LogsViewModel.cs index 5f460df..4658740 100644 --- a/src/Probel.LogReader/ViewModels/LogsViewModel.cs +++ b/src/Probel.LogReader/ViewModels/LogsViewModel.cs @@ -338,10 +338,12 @@ private void ResetFilter() Logs = new ObservableCollection(_cachedLogs); } - private void SaveConfig() => _configManager.Save(e => - { - e.Ui.IsLogOrderAsc = IsOrderByAsc; - }); + private void SaveConfig() => _configManager.Save(cfg => + { + cfg.Ui.IsLogOrderAsc = IsOrderByAsc; + cfg.Ui.IsLoggerVisible = IsLoggerVisible; + cfg.Ui.IsThreadIdVisible = IsThreadIdVisible; + }); private void SortLogs(bool sortAsc) { @@ -386,14 +388,7 @@ protected override void OnDeactivate(bool close) _eventAggregator.PublishOnUIThread(UiEvent.HideMenuFilter()); UnregisterListener(); - var t1 = Task.Run(() => - { - _configManager.Save(stg => - { - stg.Ui.IsLoggerVisible = IsLoggerVisible; - stg.Ui.IsThreadIdVisible = IsThreadIdVisible; - }); - }); + var t1 = Task.Run(() => SaveConfig()); t1.OnErrorHandle(_ui); } @@ -488,6 +483,13 @@ private void ReloadRepository() { if (_loadedRepository != null) { + /* Configuration is saved only when LogView + * is deactivated. Whenever you reloads the + * repositories, settings is reladed from files + * Therefore, this is why I save it here + */ + SaveConfig(); + LoadRepository(_loadedRepository); } } diff --git a/src/Probel.LogReader/Views/LogsView.xaml.cs b/src/Probel.LogReader/Views/LogsView.xaml.cs index 692df13..b1cf868 100644 --- a/src/Probel.LogReader/Views/LogsView.xaml.cs +++ b/src/Probel.LogReader/Views/LogsView.xaml.cs @@ -116,7 +116,7 @@ private void OnSearchKeyUp(object sender, KeyEventArgs e) private void OnTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) { - if (e.NewValue is IHierarchy day) + if (e.NewValue is IHierarchy day && day.Level == 3) { ViewModel.LoadLogs(day.Value); }