Remove `Global` from `StatusBarViewModel`.
MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -100,8 +100,8 @@ namespace WalletWasabi.Gui
try
{
SetTheme();
-
- MainWindowViewModel.Instance = new MainWindowViewModel(Global.Network, Global.UiConfig, Global.WalletManager, new StatusBarViewModel(), IoC.Get<IShell>());
+ var statusBarViewModel = new StatusBarViewModel(Global.DataDir, Global.Network, Global.Config, Global.HostedServices, Global.BitcoinStore, Global.LegalDocuments);
+ MainWindowViewModel.Instance = new MainWindowViewModel(Global.Network, Global.UiConfig, Global.WalletManager, statusBarViewModel, IoC.Get<IShell>());
await Global.InitializeNoWalletAsync();

MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -31,6 +31,7 @@ using WalletWasabi.Legal;
using WalletWasabi.Logging;
using WalletWasabi.Models;
using WalletWasabi.Services;
+using WalletWasabi.Stores;
using WalletWasabi.Wallets;
using WalletWasabi.WebClients.Wasabi;
@@ -56,10 +57,14 @@ namespace WalletWasabi.Gui.ViewModels
private volatile bool _disposedValue = false; // To detect redundant calls
- public StatusBarViewModel()
+ public StatusBarViewModel(string dataDir, Network network, Config config, HostedServices hostedServices, BitcoinStore bitcoinStore, LegalDocuments? legalDocuments)
{
- Global = Locator.Current.GetService<Global>();
- Network = Global.Network;
+ DataDir = dataDir;
+ Network = network;
+ Config = config;
+ HostedServices = hostedServices;
+ BitcoinStore = bitcoinStore;
+ LegalDocuments = legalDocuments;
Backend = BackendStatus.NotConnected;
UseTor = false;
Tor = TorStatus.NotRunning;
@@ -75,12 +80,21 @@ namespace WalletWasabi.Gui.ViewModels
private bool UseTor { get; set; }
- private Global Global { get; }
private StatusSet ActiveStatuses { get; }
public ReactiveCommand<Unit, Unit> UpdateCommand { get; set; }
- public Network Network { get; }
+ public string DataDir { get; }
+
+ private Network Network { get; }
+
+ private Config Config { get; }
+
+ private HostedServices HostedServices { get; }
+
+ private BitcoinStore BitcoinStore { get; }
+
+ private LegalDocuments? LegalDocuments { get; }
public bool UseBitcoinCore
{
@@ -151,15 +165,14 @@ namespace WalletWasabi.Gui.ViewModels
Nodes = nodes;
Synchronizer = synchronizer;
HashChain = synchronizer.BitcoinStore.SmartHeaderChain;
- UseTor = Global.Config.UseTor; // Do not make it dynamic, because if you change this config settings only next time will it activate.
- UseBitcoinCore = Global.Config.StartLocalBitcoinCoreOnStartup;
- var hostedServices = Global.HostedServices;
+ UseTor = Config.UseTor; // Do not make it dynamic, because if you change this config settings only next time will it activate.
+ UseBitcoinCore = Config.StartLocalBitcoinCoreOnStartup;
- var updateChecker = hostedServices.FirstOrDefault<UpdateChecker>();
+ var updateChecker = HostedServices.FirstOrDefault<UpdateChecker>();
Guard.NotNull(nameof(updateChecker), updateChecker);
UpdateStatus = updateChecker.UpdateStatus;
- var rpcMonitor = hostedServices.FirstOrDefault<RpcMonitor>();
+ var rpcMonitor = HostedServices.FirstOrDefault<RpcMonitor>();
BitcoinCoreStatus = rpcMonitor?.RpcStatus ?? RpcStatus.Unresponsive;
_status = ActiveStatuses.WhenAnyValue(x => x.CurrentStatus)
@@ -183,7 +196,7 @@ namespace WalletWasabi.Gui.ViewModels
.Subscribe(x => DownloadingBlock = x.EventArgs)
.DisposeWith(Disposables);
- IDisposable walletCheckingInterval = null;
+ IDisposable? walletCheckingInterval = null;
Observable.FromEventPattern<bool>(typeof(Wallet), nameof(Wallet.InitializingChanged))
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x =>
@@ -199,13 +212,12 @@ namespace WalletWasabi.Gui.ViewModels
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ =>
{
- var global = Global;
if (wallet is { })
{
var segwitActivationHeight = SmartHeader.GetStartingHeader(wallet.Network).Height;
if (wallet.LastProcessedFilter?.Header?.Height is uint lastProcessedFilterHeight
&& lastProcessedFilterHeight > segwitActivationHeight
- && global?.BitcoinStore?.SmartHeaderChain?.TipHeight is uint tipHeight
+ && BitcoinStore.SmartHeaderChain.TipHeight is uint tipHeight
&& tipHeight > segwitActivationHeight)
{
var allFilters = tipHeight - segwitActivationHeight;
@@ -342,12 +354,12 @@ namespace WalletWasabi.Gui.ViewModels
try
{
- if (Global.LegalDocuments is null || Global.LegalDocuments.Version < x.LegalDocumentsVersion)
+ if (LegalDocuments is null || LegalDocuments.Version < x.LegalDocumentsVersion)
{
- using var client = new WasabiClient(() => Global.Config.UseTor ? Global.Config.GetCurrentBackendUri() : Global.Config.GetFallbackBackendUri(), Global.Config.UseTor ? Global.Config.TorSocks5EndPoint : null);
+ using var client = new WasabiClient(() => Config.UseTor ? Config.GetCurrentBackendUri() : Config.GetFallbackBackendUri(), Config.UseTor ? Config.TorSocks5EndPoint : null);
var versions = await client.GetVersionsAsync(CancellationToken.None);
var version = versions.LegalDocumentsVersion;
- var legalFolderPath = Path.Combine(Global.DataDir, LegalDocuments.LegalFolderName);
+ var legalFolderPath = Path.Combine(DataDir, LegalDocuments.LegalFolderName);
var filePath = Path.Combine(legalFolderPath, $"{version}.txt");
var legalContent = await client.GetLegalDocumentsAsync(CancellationToken.None);

Remove `Global` from `StatusBarViewModel`.