2121using System . Text . Json ;
2222using System . Windows . Input ;
2323using J4JSoftware . DependencyInjection ;
24+ using J4JSoftware . Logging ;
2425using MahApps . Metro . Controls . Dialogs ;
2526using Microsoft . Extensions . Options ;
2627using Microsoft . Toolkit . Mvvm . ComponentModel ;
@@ -32,7 +33,8 @@ public class OptionsVM : ObservableRecipient
3233 {
3334 private readonly IAppConfig _appConfig ;
3435 private readonly IUserConfig _userConfig ;
35- private readonly J4JHostInfo _hostInfo ;
36+ private readonly string _appConfigFolder ;
37+ private readonly string _userConfigFolder ;
3638
3739 private CachedAppConfig _cachedAppConfig ;
3840 private UserConfig _prevUserConfig ;
@@ -42,12 +44,13 @@ public class OptionsVM : ObservableRecipient
4244 public OptionsVM (
4345 IAppConfig appConfig ,
4446 IUserConfig userConfig ,
45- J4JHostInfo hostInfo
47+ IJ4JHost host
4648 )
4749 {
4850 _appConfig = appConfig ;
4951 _userConfig = userConfig ;
50- _hostInfo = hostInfo ;
52+ _appConfigFolder = host . ApplicationConfigurationFolder ;
53+ _userConfigFolder = host . UserConfigurationFolder ;
5154
5255 SaveCommand = new RelayCommand ( SaveCommandHandlerAsync ) ;
5356 ReloadCommand = new RelayCommand ( ReloadCommandHandler ) ;
@@ -116,15 +119,15 @@ private async void SaveCommandHandlerAsync()
116119 var userText = JsonSerializer . Serialize ( _userConfig , options ) ;
117120
118121 await File . WriteAllTextAsync (
119- Path . Combine ( _hostInfo . UserConfigurationFolder , ViewModelLocator . UserConfigFile ) ,
122+ Path . Combine ( _userConfigFolder , ViewModelLocator . UserConfigFile ) ,
120123 userText ) ;
121124
122125 _prevUserConfig = _userConfig . Copy ( ) ;
123126
124127 var appText = JsonSerializer . Serialize ( _appConfig , options ) ;
125128
126129 await File . WriteAllTextAsync (
127- Path . Combine ( _hostInfo . ApplicationConfigurationFolder , ViewModelLocator . AppConfigFile ) ,
130+ Path . Combine ( _appConfigFolder , ViewModelLocator . AppConfigFile ) ,
128131 appText ) ;
129132
130133 _cachedAppConfig = new CachedAppConfig ( _appConfig ) ;
0 commit comments