Skip to content

Commit 9037758

Browse files
committed
PR review + fmt
1 parent 88a1d27 commit 9037758

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

App/Services/SettingsManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public SettingsManager(string? settingsFilePath = null)
8282
Directory.CreateDirectory(folder);
8383
_settingsFilePath = Path.Combine(folder, _fileName);
8484

85-
if(!File.Exists(_settingsFilePath))
85+
if (!File.Exists(_settingsFilePath))
8686
{
8787
// Create the settings file if it doesn't exist
8888
string emptyJson = JsonSerializer.Serialize(new { });

App/ViewModels/SettingsViewModel.cs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,46 @@ public SettingsViewModel(ILogger<SettingsViewModel> logger, ISettingsManager set
3535
// We disable the option in the UI if the policy is set.
3636
StartOnLoginDisabled = _startupManager.IsDisabledByPolicy();
3737

38-
this.PropertyChanged += (_, args) =>
38+
// Ensure the StartOnLogin property matches the current startup state.
39+
if (StartOnLogin != _startupManager.IsEnabled())
40+
{
41+
StartOnLogin = _startupManager.IsEnabled();
42+
}
43+
}
44+
45+
partial void OnConnectOnLaunchChanged(bool oldValue, bool newValue)
46+
{
47+
if (oldValue == newValue)
48+
return;
49+
try
50+
{
51+
_settingsManager.ConnectOnLaunch = ConnectOnLaunch;
52+
}
53+
catch (Exception ex)
3954
{
40-
if (args.PropertyName == nameof(ConnectOnLaunch))
55+
_logger.LogError($"Error saving {SettingsManager.ConnectOnLaunchKey} setting: {ex.Message}");
56+
}
57+
}
58+
59+
partial void OnStartOnLoginChanged(bool oldValue, bool newValue)
60+
{
61+
if (oldValue == newValue)
62+
return;
63+
try
64+
{
65+
_settingsManager.StartOnLogin = StartOnLogin;
66+
if (StartOnLogin)
4167
{
42-
try
43-
{
44-
_settingsManager.ConnectOnLaunch = ConnectOnLaunch;
45-
}
46-
catch (Exception ex)
47-
{
48-
_logger.LogError($"Error saving {SettingsManager.ConnectOnLaunchKey} setting: {ex.Message}");
49-
}
68+
_startupManager.Enable();
5069
}
51-
else if (args.PropertyName == nameof(StartOnLogin))
70+
else
5271
{
53-
try
54-
{
55-
_settingsManager.StartOnLogin = StartOnLogin;
56-
if (StartOnLogin)
57-
{
58-
_startupManager.Enable();
59-
}
60-
else
61-
{
62-
_startupManager.Disable();
63-
}
64-
}
65-
catch (Exception ex)
66-
{
67-
_logger.LogError($"Error saving {SettingsManager.StartOnLoginKey} setting: {ex.Message}");
68-
}
72+
_startupManager.Disable();
6973
}
70-
};
71-
72-
// Ensure the StartOnLogin property matches the current startup state.
73-
if (StartOnLogin != _startupManager.IsEnabled())
74+
}
75+
catch (Exception ex)
7476
{
75-
StartOnLogin = _startupManager.IsEnabled();
77+
_logger.LogError($"Error saving {SettingsManager.StartOnLoginKey} setting: {ex.Message}");
7678
}
7779
}
7880
}

App/Views/Pages/SettingsMainPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public sealed partial class SettingsMainPage : Page
99

1010
public SettingsMainPage(SettingsViewModel viewModel)
1111
{
12-
ViewModel = viewModel; // already initialized
12+
ViewModel = viewModel;
1313
InitializeComponent();
1414
}
1515
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy