Use ICommand instead of WhenAnyValue
MODIFY
WalletWasabi.Fluent/ViewModels/Settings/GeneralSettingsTabViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/GeneralSettingsTabViewModel.cs
@@ -7,6 +7,8 @@ using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Gui;
using WalletWasabi.Gui.Models;
using WalletWasabi.Logging;
+using System.Windows.Input;
+using DynamicData;
namespace WalletWasabi.Fluent.ViewModels.Settings
{
@@ -30,6 +32,8 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
[AutoNotify] private FeeDisplayFormat _selectedFeeDisplayFormat;
[AutoNotify] private bool _runOnSystemStartup;
+ public ICommand StartUpCommand { get; }
+
public GeneralSettingsTabViewModel()
{
_darkModeEnabled = Services.UiConfig.DarkModeEnabled;
@@ -55,19 +59,17 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
.Skip(1)
.Subscribe(x => Services.UiConfig.Autocopy = x);
- this.WhenAnyValue(x => x.RunOnSystemStartup)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Skip(1)
- .Subscribe(async runOnStartup =>
+ StartUpCommand = ReactiveCommand.Create(async () =>
{
try
{
- await StartupHelper.ModifyStartupSettingAsync(runOnStartup);
- Services.UiConfig.RunOnSystemStartup = runOnStartup;
+ await StartupHelper.ModifyStartupSettingAsync(RunOnSystemStartup);
+ Services.UiConfig.RunOnSystemStartup = RunOnSystemStartup;
}
catch (Exception ex)
{
Logger.LogError(ex);
+ RunOnSystemStartup = !RunOnSystemStartup;
await ShowErrorAsync(Title, "Couldn't save your change, please see the logs for further information.", "Error occured.");
}
});

MODIFY
WalletWasabi.Fluent/Views/Settings/GeneralSettingsTabView.axaml
WalletWasabi.Fluent/Views/Settings/GeneralSettingsTabView.axaml
<DockPanel>
<TextBlock Text="Start Wasabi with the system" />
- <ToggleSwitch IsChecked="{Binding RunOnSystemStartup}" />
+ <ToggleSwitch IsChecked="{Binding RunOnSystemStartup}" Command="{Binding StartUpCommand}" />
</DockPanel>
<DockPanel>

Use ICommand instead of WhenAnyValue