[skip ci] Use working buttons to enqueue dequeue
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabView.xaml
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabView.xaml
<TextBlock Text="{Binding WarningMessage}" Classes="warningMessage" />
<TextBox Text="{Binding Password}" PasswordChar="*" Watermark="Password" UseFloatingWatermark="True" MinWidth="173" />
<DockPanel LastChildFill="True" VerticalAlignment="Top">
- <Button Content="Enqueue Selected Coins for CoinJoin" Command="{Binding EnqueueCommand}" DockPanel.Dock="Right" />
+ <Button Command="{Binding EnqueueCommand}" DockPanel.Dock="Right" IsEnabled="{Binding !IsEnqueueBusy}">
+ <StackPanel Orientation="Horizontal">
+ <controls:Spinner Height="20" Width="20" IsVisible="{Binding IsEnqueueBusy}" Margin="0 0 8 0" />
+ <TextBlock Text="{Binding EnqueueButtonText}" />
+ </StackPanel>
+ </Button>
<Grid />
</DockPanel>
<DockPanel LastChildFill="True" VerticalAlignment="Top">
- <Button Content="Dequeue" Command="{Binding DequeueCommand}" DockPanel.Dock="Right" />
+ <Button Command="{Binding DequeueCommand}" DockPanel.Dock="Right" IsEnabled="{Binding !IsDequeueBusy}">
+ <StackPanel Orientation="Horizontal">
+ <controls:Spinner Height="20" Width="20" IsVisible="{Binding IsDequeueBusy}" Margin="0 0 8 0" />
+ <TextBlock Text="{Binding DequeueButtonText}" />
+ </StackPanel>
+ </Button>
<Grid />
</DockPanel>
</StackPanel>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -33,6 +33,14 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private Money _amountQueued;
private string _warningMessage;
private const int PreSelectMaxAnonSetExcludingCondition = 50;
+ private bool _isEnqueueBusy;
+ private bool _isDequeueBusy;
+ private string _enqueueButtonText;
+ private const string EnqueueButtonTextString = "Enqueue Selected Coins for CoinJoin";
+ private const string EnqueuingButtonTextString = "Queuing coins...";
+ private string _dequeueButtonText;
+ private const string DequeueButtonTextString = "Dequeue";
+ private const string DequeuingButtonTextString = "Dequeuing coins...";
public CoinJoinTabViewModel(WalletViewModel walletViewModel)
: base("CoinJoin", walletViewModel)
@@ -101,6 +109,52 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
});
DequeueCommand = ReactiveCommand.Create(async () =>
+ {
+ await DoDequeueAsync();
+ });
+
+ this.WhenAnyValue(x => x.Password).Subscribe(async x =>
+ {
+ if (x.NotNullAndNotEmpty())
+ {
+ char lastChar = x.Last();
+ if (lastChar == '\r' || lastChar == '\n') // If the last character is cr or lf then act like it'd be a sign to do the job.
+ {
+ Password = x.TrimEnd('\r', '\n');
+ await DoEnqueueAsync();
+ }
+ }
+ });
+
+ this.WhenAnyValue(x => x.IsEnqueueBusy).Subscribe(busy =>
+ {
+ if (busy)
+ {
+ EnqueueButtonText = EnqueuingButtonTextString;
+ }
+ else
+ {
+ EnqueueButtonText = EnqueueButtonTextString;
+ }
+ });
+
+ this.WhenAnyValue(x => x.IsDequeueBusy).Subscribe(busy =>
+ {
+ if (busy)
+ {
+ DequeueButtonText = DequeuingButtonTextString;
+ }
+ else
+ {
+ DequeueButtonText = DequeueButtonTextString;
+ }
+ });
+ }
+
+ private async Task DoDequeueAsync()
+ {
+ IsDequeueBusy = true;
+ try
{
WarningMessage = "";
@@ -129,23 +183,17 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
SetWarningMessage(warningMessage);
return;
}
- });
-
- this.WhenAnyValue(x => x.Password).Subscribe(async x =>
- {
- if (x.NotNullAndNotEmpty())
- {
- char lastChar = x.Last();
- if (lastChar == '\r' || lastChar == '\n') // If the last character is cr or lf then act like it'd be a sign to do the job.
- {
- Password = x.TrimEnd('\r', '\n');
- await DoEnqueueAsync();
}
+ finally
+ {
+ IsDequeueBusy = false;
}
- });
}
private async Task DoEnqueueAsync()
+ {
+ IsEnqueueBusy = true;
+ try
{
WarningMessage = "";
Password = Guard.Correct(Password);
@@ -179,6 +227,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Password = string.Empty;
}
+ finally
+ {
+ IsEnqueueBusy = false;
+ }
+ }
private void ChaumianClient_CoinDequeued(object sender, SmartCoin e)
{
@@ -353,6 +406,30 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set { this.RaiseAndSetIfChanged(ref _warningMessage, value); }
}
+ public bool IsEnqueueBusy
+ {
+ get { return _isEnqueueBusy; }
+ set { this.RaiseAndSetIfChanged(ref _isEnqueueBusy, value); }
+ }
+
+ public bool IsDequeueBusy
+ {
+ get { return _isDequeueBusy; }
+ set { this.RaiseAndSetIfChanged(ref _isDequeueBusy, value); }
+ }
+
+ public string EnqueueButtonText
+ {
+ get { return _enqueueButtonText; }
+ set { this.RaiseAndSetIfChanged(ref _enqueueButtonText, value); }
+ }
+
+ public string DequeueButtonText
+ {
+ get { return _dequeueButtonText; }
+ set { this.RaiseAndSetIfChanged(ref _dequeueButtonText, value); }
+ }
+
public ReactiveCommand EnqueueCommand { get; }
public ReactiveCommand DequeueCommand { get; }

[skip ci] Use working buttons to enqueue dequeue