@@ -12,15 +12,16 @@ namespace X4LogWatcher
1212 public class Config : INotifyPropertyChanged
1313 {
1414 private static readonly int MaxRecentProfiles = 5 ;
15- private bool _isSaving = false ; // Flag to prevent recursive saves
15+ private bool _isSaving ; // Flag to prevent recursive saves
1616
1717 // Backing fields for properties
1818 private ObservableCollection < string > _recentProfiles = new ObservableCollection < string > ( ) ;
1919 private string ? _activeProfile ;
2020 private string ? _lastLogFolderPath ;
2121 private string _logFileExtension = ".log" ;
2222 private bool _skipSignatureErrors = true ;
23- private bool _realTimeStamping = false ;
23+ private bool _realTimeStamping ;
24+ private JsonSerializerOptions _jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true } ;
2425
2526 // Properties with notification
2627 public ObservableCollection < string > RecentProfiles
@@ -88,7 +89,7 @@ public static void SaveConfig(Config config)
8889 } ;
8990
9091 // Serialize the config to JSON and write to file
91- string jsonConfig = JsonSerializer . Serialize ( configToSave , new JsonSerializerOptions { WriteIndented = true } ) ;
92+ string jsonConfig = JsonSerializer . Serialize ( configToSave , config . _jsonSerializerOptions ) ;
9293 File . WriteAllText ( configPath , jsonConfig ) ;
9394 }
9495 catch ( Exception ex )
@@ -156,11 +157,8 @@ public void AddRecentProfile(string profilePath)
156157
157158 try
158159 {
159- // Remove the profile if it already exists
160- if ( RecentProfiles . Contains ( profilePath ) )
161- {
162- RecentProfiles . Remove ( profilePath ) ;
163- }
160+ // Remove the profile if it already exists (Remove returns true if found and removed)
161+ RecentProfiles . Remove ( profilePath ) ;
164162
165163 // Add the profile to the beginning of the list
166164 RecentProfiles . Insert ( 0 , profilePath ) ;
0 commit comments