no need to use integer to string conversion in the ui.
MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/ManualCoinJoinProfileDialogViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/ManualCoinJoinProfileDialogViewModel.cs
@@ -12,16 +12,18 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs;
public partial class ManualCoinJoinProfileDialogViewModel : DialogViewModelBase<ManualCoinJoinProfileViewModel?>
{
[AutoNotify] private bool _autoCoinjoin;
- [AutoNotify] private string _minAnonScoreTarget;
- [AutoNotify] private string _maxAnonScoreTarget;
+ [AutoNotify] private int _minAnonScoreTarget;
+ [AutoNotify] private int _maxAnonScoreTarget;
[AutoNotify] private TimeFrameItem[] _timeFrames;
[AutoNotify] private TimeFrameItem _selectedTimeFrame;
public ManualCoinJoinProfileDialogViewModel(CoinJoinProfileViewModelBase current)
{
_autoCoinjoin = true;
- _minAnonScoreTarget = current.MinAnonScoreTarget.ToString();
- _maxAnonScoreTarget = current.MaxAnonScoreTarget.ToString();
+
+ _minAnonScoreTarget = current.MinAnonScoreTarget;
+ _maxAnonScoreTarget = current.MaxAnonScoreTarget;
+
_timeFrames = new[]
{
new TimeFrameItem("Hours", TimeSpan.Zero),
@@ -33,30 +35,39 @@ public partial class ManualCoinJoinProfileDialogViewModel : DialogViewModelBase<
_selectedTimeFrame = _timeFrames.FirstOrDefault(tf => tf.TimeFrame == TimeSpan.FromHours(current.FeeRateMedianTimeFrameHours)) ?? _timeFrames.First();
SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);
+
EnableBack = false;
- NextCommand = ReactiveCommand.Create(() =>
+ this.WhenAnyValue(x => x.MinAnonScoreTarget)
+ .Subscribe(
+ x =>
{
- var auto = AutoCoinjoin;
- var min = int.Parse(MinAnonScoreTarget);
- var max = int.Parse(MaxAnonScoreTarget);
- var hours = (int)Math.Floor(SelectedTimeFrame.TimeFrame.TotalHours);
-
- Close(DialogResultKind.Normal, new ManualCoinJoinProfileViewModel(auto, min, max, hours));
- });
-
- this.ValidateProperty(x => x.MinAnonScoreTarget, errors => ValidateInteger(MinAnonScoreTarget, nameof(MinAnonScoreTarget), errors));
- this.ValidateProperty(x => x.MaxAnonScoreTarget, errors => ValidateInteger(MaxAnonScoreTarget, nameof(MaxAnonScoreTarget), errors));
+ if (x >= MaxAnonScoreTarget)
+ {
+ MaxAnonScoreTarget = x + 1;
}
+ });
- private void ValidateInteger(string text, string propertyName, IValidationErrors errors)
+ this.WhenAnyValue(x => x.MaxAnonScoreTarget)
+ .Subscribe(
+ x =>
{
- if (int.TryParse(text, out _))
+ if (x <= MinAnonScoreTarget)
{
- return;
+ MinAnonScoreTarget = x - 1;
}
+ });
+
+
+ NextCommand = ReactiveCommand.Create(() =>
+ {
+ var auto = AutoCoinjoin;
+ var min = MinAnonScoreTarget;
+ var max = MaxAnonScoreTarget;
+ var hours = (int)Math.Floor(SelectedTimeFrame.TimeFrame.TotalHours);
- errors.Add(ErrorSeverity.Error, $"Field {propertyName} is not an integer.");
+ Close(DialogResultKind.Normal, new ManualCoinJoinProfileViewModel(auto, min, max, hours));
+ });
}
public record TimeFrameItem(string Name, TimeSpan TimeFrame)

no need to use integer to string conversion in the ui.