handle round starts, ends, and errors.
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs
@@ -35,7 +35,7 @@ public enum Trigger
AutoPlayTimeout,
PlebStop,
CoinReceive,
- RoundComplete,
+ RoundStartFailed,
RoundStart
}
@@ -54,11 +54,16 @@ public partial class CoinJoinStateViewModel : ViewModelBase
[AutoNotify] private string _elapsedTime;
[AutoNotify] private string _remainingTime;
- private readonly MusicStatusMessageViewModel _countDownMessage = new () {Message = "Waiting to auto-start coinjoin"};
+ private readonly MusicStatusMessageViewModel _countDownMessage = new()
+ { Message = "Waiting to auto-start coinjoin" };
+
private readonly MusicStatusMessageViewModel _coinJoiningMessage = new() { Message = "Coinjoining" };
- private readonly MusicStatusMessageViewModel _pauseMessage = new() { Message = "Coinjoin is paused until the next round" };
+ private readonly MusicStatusMessageViewModel _pauseMessage = new()
+ { Message = "Coinjoin is paused until the next round" };
+
private readonly MusicStatusMessageViewModel _stoppedMessage = new() { Message = "Coinjoin is stopped" };
+ private readonly MusicStatusMessageViewModel _startErrorMessage = new() { };
private DateTime _autoStartTime;
private DateTime _countDownStarted;
@@ -105,8 +110,8 @@ public partial class CoinJoinStateViewModel : ViewModelBase
_machine.Configure(State.ManualPlaying)
.Permit(Trigger.Stop, State.Stopped)
- .Permit(Trigger.RoundComplete, State.ManualFinished)
- .Permit(Trigger.RoundComplete, State.ManualLoading)
+ .Permit(Trigger.RoundStartFailed, State.ManualFinished)
+ .Permit(Trigger.RoundStart, State.ManualLoading)
.OnEntry(() =>
{
PlayVisible = false;
@@ -188,8 +193,8 @@ public partial class CoinJoinStateViewModel : ViewModelBase
.SubstateOf(State.AutoCoinJoin)
.Permit(Trigger.Pause, State.Paused)
.Permit(Trigger.PlebStop, State.Paused)
- .Permit(Trigger.RoundComplete, State.AutoFinished)
- .Permit(Trigger.RoundComplete, State.AutoLoading)
+ .Permit(Trigger.RoundStartFailed, State.AutoFinished)
+ .Permit(Trigger.RoundStart, State.AutoPlaying)
.OnEntry(() =>
{
IsAutoWaiting = false;
@@ -205,7 +210,16 @@ public partial class CoinJoinStateViewModel : ViewModelBase
_machine.Configure(State.AutoFinished)
.SubstateOf(State.AutoCoinJoin)
- .Permit(Trigger.CoinReceive, State.AutoPlaying);
+ .Permit(Trigger.CoinReceive, State.AutoPlaying)
+ .OnEntry(() =>
+ {
+ PauseVisible = false;
+ IsAutoWaiting = true;
+
+ _startErrorMessage.Message = "Coinjoin stopped. No coins to mix.";
+
+ CurrentStatus = _startErrorMessage;
+ });
PlayCommand = ReactiveCommand.Create(() => _machine.Fire(Trigger.Play));
@@ -230,15 +244,19 @@ public partial class CoinJoinStateViewModel : ViewModelBase
switch (e)
{
case CoinJoinCompletedEventArgs coinJoinCompletedEventArgs:
- break;
- case LoadedEventArgs loadedEventArgs:
+ // TODO implement a message to show success / failure.
break;
case StartedEventArgs startedEventArgs:
+ _machine.Fire(Trigger.RoundStart);
break;
+
case StartErrorEventArgs startErrorEventArgs:
+ _machine.Fire(Trigger.RoundStartFailed);
break;
+
case StoppedEventArgs stoppedEventArgs:
break;
+
default:
throw new ArgumentOutOfRangeException(nameof(e));
}

handle round starts, ends, and errors.