Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
Fix #99, Fix #98 - Settings are lost after log refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
jibedoubleve committed Jan 20, 2022
1 parent f6b44d4 commit 4fc04ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions src/Probel.LogReader/ViewModels/LogsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,12 @@ private void ResetFilter()
Logs = new ObservableCollection<LogRow>(_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)
{
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Probel.LogReader/Views/LogsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void OnSearchKeyUp(object sender, KeyEventArgs e)

private void OnTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (e.NewValue is IHierarchy<DateTime> day)
if (e.NewValue is IHierarchy<DateTime> day && day.Level == 3)
{
ViewModel.LoadLogs(day.Value);
}
Expand Down

0 comments on commit 4fc04ab

Please sign in to comment.