dont let global permeate further than mainviewmodel.
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -9,6 +9,7 @@ using WalletWasabi.Fluent.ViewModels.Dialogs;
using Global = WalletWasabi.Gui.Global;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Fluent.ViewModels.Navigation;
+using WalletWasabi.Fluent.ViewModels.Settings;
namespace WalletWasabi.Fluent.ViewModels
{
@@ -44,7 +45,9 @@ namespace WalletWasabi.Fluent.ViewModels
var addWalletPage = new AddWalletPageViewModel(global.LegalDocuments, global.WalletManager, global.BitcoinStore, global.Network);
- _navBar = new NavBarViewModel(Router, walletManager, addWalletPage);
+ var settingsPage = new SettingsPageViewModel(global.Config, global.UiConfig);
+
+ _navBar = new NavBarViewModel(Router, walletManager, addWalletPage, settingsPage);
this.WhenAnyValue(x => x.DialogScreen!.IsDialogOpen)
.ObserveOn(RxApp.MainThreadScheduler)

MODIFY
WalletWasabi.Fluent/ViewModels/NavBar/NavBarViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBar/NavBarViewModel.cs
@@ -29,7 +29,11 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
private Action? _toggleAction;
private Action? _collapseOnClickAction;
- public NavBarViewModel(RoutingState router, WalletManagerViewModel walletManager, AddWalletPageViewModel addWalletPage)
+ public NavBarViewModel(
+ RoutingState router,
+ WalletManagerViewModel walletManager,
+ AddWalletPageViewModel addWalletPage,
+ SettingsPageViewModel settingsPage)
{
Router = router;
_walletManager = walletManager;
@@ -37,7 +41,6 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
_bottomItems = new ObservableCollection<NavBarItemViewModel>();
var homePage = new HomePageViewModel(walletManager, addWalletPage);
- var settingsPage = new SettingsPageViewModel();
var searchPage = new SearchPageViewModel(walletManager);
RegisterCategories(searchPage);

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/BitcoinTabTabViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/BitcoinTabTabViewModel.cs
@@ -20,15 +20,15 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
private bool _stopLocalBitcoinCoreOnShutdown;
private string _bitcoinP2PEndPoint;
- public BitcoinTabTabViewModel(Global global) : base(global)
+ public BitcoinTabTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig)
{
this.ValidateProperty(x => x.BitcoinP2PEndPoint, ValidateBitcoinP2PEndPoint);
- _network = global.Config.Network;
- _startLocalBitcoinCoreOnStartup = global.Config.StartLocalBitcoinCoreOnStartup;
- _localBitcoinCoreDataDir = global.Config.LocalBitcoinCoreDataDir;
- _stopLocalBitcoinCoreOnShutdown = global.Config.StopLocalBitcoinCoreOnShutdown;
- _bitcoinP2PEndPoint = global.Config.GetP2PEndpoint().ToString(defaultPort: -1);
+ _network = config.Network;
+ _startLocalBitcoinCoreOnStartup = config.StartLocalBitcoinCoreOnStartup;
+ _localBitcoinCoreDataDir = config.LocalBitcoinCoreDataDir;
+ _stopLocalBitcoinCoreOnShutdown = config.StopLocalBitcoinCoreOnShutdown;
+ _bitcoinP2PEndPoint = config.GetP2PEndpoint().ToString(defaultPort: -1);
this.WhenAnyValue(
x => x.Network,

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/GeneralTabTabViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/GeneralTabTabViewModel.cs
@@ -20,18 +20,18 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
private FeeDisplayFormat _selectedFeeDisplayFormat;
private string _dustThreshold;
- public GeneralTabTabViewModel(Global global) : base(global)
+ public GeneralTabTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig)
{
this.ValidateProperty(x => x.DustThreshold, ValidateDustThreshold);
- _darkModeEnabled = global.UiConfig.DarkModeEnabled;
- _autocopy = global.UiConfig.Autocopy;
- _customFee = global.UiConfig.IsCustomFee;
- _customChangeAddress = global.UiConfig.IsCustomChangeAddress;
- _selectedFeeDisplayFormat = Enum.IsDefined(typeof(FeeDisplayFormat), global.UiConfig.FeeDisplayFormat)
- ? (FeeDisplayFormat)global.UiConfig.FeeDisplayFormat
+ _darkModeEnabled = uiConfig.DarkModeEnabled;
+ _autocopy = uiConfig.Autocopy;
+ _customFee = uiConfig.IsCustomFee;
+ _customChangeAddress = uiConfig.IsCustomChangeAddress;
+ _selectedFeeDisplayFormat = Enum.IsDefined(typeof(FeeDisplayFormat), uiConfig.FeeDisplayFormat)
+ ? (FeeDisplayFormat)uiConfig.FeeDisplayFormat
: FeeDisplayFormat.SatoshiPerByte;
- _dustThreshold = global.Config.DustThreshold.ToString();
+ _dustThreshold = config.DustThreshold.ToString();
this.WhenAnyValue(x => x.DustThreshold)
.ObserveOn(RxApp.TaskpoolScheduler)
@@ -43,29 +43,29 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
.Skip(1)
.Subscribe(x =>
{
- global.UiConfig.DarkModeEnabled = x;
+ uiConfig.DarkModeEnabled = x;
IsRestartNeeded(x);
});
this.WhenAnyValue(x => x.Autocopy)
.ObserveOn(RxApp.TaskpoolScheduler)
.Skip(1)
- .Subscribe(x => global.UiConfig.Autocopy = x);
+ .Subscribe(x => uiConfig.Autocopy = x);
this.WhenAnyValue(x => x.CustomFee)
.ObserveOn(RxApp.TaskpoolScheduler)
.Skip(1)
- .Subscribe(x => global.UiConfig.IsCustomFee = x);
+ .Subscribe(x => uiConfig.IsCustomFee = x);
this.WhenAnyValue(x => x.CustomChangeAddress)
.ObserveOn(RxApp.TaskpoolScheduler)
.Skip(1)
- .Subscribe(x => global.UiConfig.IsCustomChangeAddress = x);
+ .Subscribe(x => uiConfig.IsCustomChangeAddress = x);
this.WhenAnyValue(x => x.SelectedFeeDisplayFormat)
.ObserveOn(RxApp.MainThreadScheduler)
.Skip(1)
- .Subscribe(x => global.UiConfig.FeeDisplayFormat = (int)x);
+ .Subscribe(x => uiConfig.FeeDisplayFormat = (int)x);
}
public bool DarkModeEnabled

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/NetworkTabTabViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/NetworkTabTabViewModel.cs
@@ -16,13 +16,13 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
private bool _terminateTorOnExit;
private string _torSocks5EndPoint;
- public NetworkTabTabViewModel(Global global) : base(global)
+ public NetworkTabTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig)
{
this.ValidateProperty(x => x.TorSocks5EndPoint, ValidateTorSocks5EndPoint);
- _useTor = global.Config.UseTor;
- _terminateTorOnExit = global.Config.TerminateTorOnExit;
- _torSocks5EndPoint = global.Config.TorSocks5EndPoint.ToString(-1);
+ _useTor = config.UseTor;
+ _terminateTorOnExit = config.TerminateTorOnExit;
+ _torSocks5EndPoint = config.TorSocks5EndPoint.ToString(-1);
this.WhenAnyValue(
x => x.UseTor,

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/PrivacyTabTabViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/PrivacyTabTabViewModel.cs
@@ -11,11 +11,11 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
private int _mediumPrivacyLevel;
private int _strongPrivacyLevel;
- public PrivacyTabTabViewModel(Global global) : base(global)
+ public PrivacyTabTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig)
{
- _minimalPrivacyLevel = global.Config.PrivacyLevelSome;
- _mediumPrivacyLevel = global.Config.PrivacyLevelFine;
- _strongPrivacyLevel = global.Config.PrivacyLevelStrong;
+ _minimalPrivacyLevel = config.PrivacyLevelSome;
+ _mediumPrivacyLevel = config.PrivacyLevelFine;
+ _strongPrivacyLevel = config.PrivacyLevelStrong;
this.WhenAnyValue(
x => x.MinimalPrivacyLevel,

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
@@ -13,18 +13,16 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
private bool _isModified;
private int _selectedTab;
- public SettingsPageViewModel()
+ public SettingsPageViewModel(Config config, UiConfig uiConfig)
{
- var global = Locator.Current.GetService<Global>();
-
Title = "Settings";
_selectedTab = 0;
- GeneralTab = new GeneralTabTabViewModel(global);
- PrivacyTab = new PrivacyTabTabViewModel(global);
- NetworkTab = new NetworkTabTabViewModel(global);
- BitcoinTab = new BitcoinTabTabViewModel(global);
+ GeneralTab = new GeneralTabTabViewModel(config, uiConfig);
+ PrivacyTab = new PrivacyTabTabViewModel(config, uiConfig);
+ NetworkTab = new NetworkTabTabViewModel(config, uiConfig);
+ BitcoinTab = new BitcoinTabTabViewModel(config, uiConfig);
}
protected override void OnNavigatedTo(bool inStack, CompositeDisposable disposable)

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/SettingsTabViewModelBase.cs
WalletWasabi.Fluent/ViewModels/Settings/SettingsTabViewModelBase.cs
@@ -11,12 +11,12 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
protected const int ThrottleTime = 500;
public static event EventHandler<RestartNeededEventArgs>? RestartNeeded;
- protected SettingsTabViewModelBase(Global global)
+ protected SettingsTabViewModelBase(Config config, UiConfig uiConfig)
{
- ConfigOnOpen = new Config(global.Config.FilePath);
+ ConfigOnOpen = new Config(config.FilePath);
ConfigOnOpen.LoadFile();
- UiConfigOnOpen = new UiConfig(global.UiConfig.FilePath);
+ UiConfigOnOpen = new UiConfig(uiConfig.FilePath);
UiConfigOnOpen.LoadFile();
}

dont let global permeate further than mainviewmodel.