use member instead of local in subscibe
MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -27,6 +27,8 @@ namespace WalletWasabi.Gui.ViewModels
public class StatusBarViewModel : ViewModelBase
{
private CompositeDisposable Disposables { get; } = new CompositeDisposable();
+ private NodesCollection Nodes { get; }
+ private WasabiSynchronizer Synchronizer { get; }
private UpdateStatus _updateStatus;
private bool _updateAvailable;
@@ -42,20 +44,21 @@ namespace WalletWasabi.Gui.ViewModels
public StatusBarViewModel(NodesCollection nodes, WasabiSynchronizer synchronizer, UpdateChecker updateChecker)
{
UpdateStatus = UpdateStatus.Latest;
- SetPeers(nodes.Count);
+ Nodes = nodes;
+ Synchronizer = synchronizer;
BlocksLeft = 0;
FiltersLeft = synchronizer.GetFiltersLeft();
Observable.FromEventPattern<NodeEventArgs>(nodes, nameof(nodes.Added))
.Subscribe(x =>
{
- SetPeers(nodes.Count);
+ SetPeers(Nodes.Count);
}).DisposeWith(Disposables);
Observable.FromEventPattern<NodeEventArgs>(nodes, nameof(nodes.Removed))
.Subscribe(x =>
{
- SetPeers(nodes.Count);
+ SetPeers(Nodes.Count);
}).DisposeWith(Disposables);
Observable.FromEventPattern<int>(typeof(WalletService), nameof(WalletService.ConcurrentBlockDownloadNumberChanged))
@@ -66,27 +69,28 @@ namespace WalletWasabi.Gui.ViewModels
Observable.FromEventPattern(synchronizer, nameof(synchronizer.NewFilter)).Subscribe(x =>
{
- FiltersLeft = synchronizer.GetFiltersLeft();
+ FiltersLeft = Synchronizer.GetFiltersLeft();
}).DisposeWith(Disposables);
- synchronizer.WhenAnyValue(x => x.TorStatus).Subscribe(_ =>
+ synchronizer.WhenAnyValue(x => x.TorStatus).Subscribe(status =>
{
- SetTor(synchronizer.TorStatus);
+ SetTor(status);
+ SetPeers(Nodes.Count);
}).DisposeWith(Disposables);
synchronizer.WhenAnyValue(x => x.BackendStatus).Subscribe(_ =>
{
- Backend = synchronizer.BackendStatus;
+ Backend = Synchronizer.BackendStatus;
}).DisposeWith(Disposables);
synchronizer.WhenAnyValue(x => x.BestBlockchainHeight).Subscribe(_ =>
{
- FiltersLeft = synchronizer.GetFiltersLeft();
+ FiltersLeft = Synchronizer.GetFiltersLeft();
}).DisposeWith(Disposables);
- synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Subscribe(_ =>
+ synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Subscribe(usd =>
{
- BtcPrice = $"${(long)synchronizer.UsdExchangeRate}";
+ BtcPrice = $"${(long)usd}";
}).DisposeWith(Disposables);
Observable.FromEventPattern<bool>(synchronizer, nameof(synchronizer.ResponseArrivedIsGenSocksServFail))
@@ -340,7 +344,6 @@ namespace WalletWasabi.Gui.ViewModels
{
// Set peers to 0 if Tor is not running, because we get Tor status from backend answer so it's seem to the user that peers are connected over clearnet, while they don't.
Tor = tor;
- SetPeers(Peers);
}
#region IDisposable Support

use member instead of local in subscibe