Save on UiConfig modification
MODIFY
WalletWasabi.Fluent/ViewModels/Settings/GeneralTabViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/GeneralTabViewModel.cs
@@ -9,7 +9,6 @@ using ReactiveUI;
using WalletWasabi.Gui;
using WalletWasabi.Gui.Models;
using WalletWasabi.Gui.Validation;
-using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Models;
namespace WalletWasabi.Fluent.ViewModels.Settings

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
+using System.Reactive.Disposables;
using ReactiveUI;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Gui;
@@ -16,6 +17,11 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
_selectedTab = 0;
+ // TODO: Restart wasabi message
+ // IsModified = !Global.Config.AreDeepEqual(config);
+
+ this.WhenNavigatedTo(() =>
+ {
var config = new Config(global.Config.FilePath);
config.LoadOrCreateDefaultFile();
@@ -24,16 +30,19 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
NetworkTab = new NetworkTabViewModel(Global, config);
BitcoinTab = new BitcoinTabViewModel(Global, config);
- // TODO: Restart wasabi message
- IsModified = !Global.Config.AreDeepEqual(config);
+ return Disposable.Create(() =>
+ {
+ GeneralTab.Dispose();
+ });
+ });
}
public Global Global { get; }
- public GeneralTabViewModel GeneralTab { get; }
- public PrivacyTabViewModel PrivacyTab { get; }
- public NetworkTabViewModel NetworkTab { get; }
- public BitcoinTabViewModel BitcoinTab { get; }
+ public GeneralTabViewModel? GeneralTab { get; set; }
+ public PrivacyTabViewModel? PrivacyTab { get; set; }
+ public NetworkTabViewModel? NetworkTab { get; set; }
+ public BitcoinTabViewModel? BitcoinTab { get; set; }
public bool IsModified
{

MODIFY
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
@@ -308,12 +308,6 @@ namespace WalletWasabi.Gui.Tabs
.DisposeWith(disposables);
this.RaisePropertyChanged(nameof(IsPinSet)); // Fire now otherwise the button won't update for restart.
- Global.UiConfig.WhenAnyValue(x => x.LockScreenPinHash, x => x.Autocopy, x => x.IsCustomFee, x => x.IsCustomChangeAddress)
- .Throttle(TimeSpan.FromSeconds(1))
- .ObserveOn(RxApp.TaskpoolScheduler)
- .Subscribe(_ => Global.UiConfig.ToFile())
- .DisposeWith(disposables);
-
Global.UiConfig.WhenAnyValue(x => x.FeeDisplayFormat)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => SelectedFeeDisplayFormat = (FeeDisplayFormat)x)

MODIFY
WalletWasabi.Gui/UiConfig.cs
WalletWasabi.Gui/UiConfig.cs
+using System;
using Avalonia.Controls;
using Newtonsoft.Json;
using System.ComponentModel;
+using System.Reactive.Linq;
+using ReactiveUI;
using WalletWasabi.Bases;
using WalletWasabi.Gui.Converters;
using WalletWasabi.Gui.Models.Sorting;
@@ -24,6 +27,15 @@ namespace WalletWasabi.Gui
public UiConfig(string filePath) : base(filePath)
{
+ this.WhenAnyValue(
+ x => x.LockScreenPinHash,
+ x => x.Autocopy,
+ x => x.IsCustomFee,
+ x => x.IsCustomChangeAddress)
+ .Throttle(TimeSpan.FromSeconds(1))
+ .Skip(1) // Won't save on UiConfig creation.
+ .ObserveOn(RxApp.TaskpoolScheduler)
+ .Subscribe(_ => ToFile());
}
[JsonProperty(PropertyName = "WindowState")]

Save on UiConfig modification