remove dialog call and check change pocket availability
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacyControlViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacyControlViewModel.cs
@@ -20,14 +20,15 @@ public partial class PrivacyControlViewModel : DialogViewModelBase<IEnumerable<S
private readonly bool _isSilent;
private readonly IEnumerable<SmartCoin>? _usedCoins;
- public PrivacyControlViewModel(Wallet wallet, TransactionInfo transactionInfo, IEnumerable<SmartCoin>? usedCoins, bool isSilent, Money? targetAmount = null)
+ public PrivacyControlViewModel(Wallet wallet, TransactionInfo transactionInfo, IEnumerable<SmartCoin>? usedCoins, bool isSilent)
{
_wallet = wallet;
_transactionInfo = transactionInfo;
_isSilent = isSilent;
_usedCoins = usedCoins;
- LabelSelection = new LabelSelectionViewModel(targetAmount ?? _transactionInfo.Amount);
+ var amount = transactionInfo.MinimumRequiredAmount == Money.Zero ? transactionInfo.Amount : transactionInfo.MinimumRequiredAmount;
+ LabelSelection = new LabelSelectionViewModel(amount);
SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: false);
EnableBack = true;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -88,10 +88,6 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
await PrivacySuggestions.BuildPrivacySuggestionsAsync(_wallet, _info, _destination, ca.TransactionResult, _isFixedAmount, _cancellationTokenSource.Token);
}
- else if (x is PocketSuggestionViewModel)
- {
- await OnChangePocketsAsync();
- }
});
PrivacySuggestions.WhenAnyValue(x => x.IsOpen)
@@ -145,6 +141,8 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
await PrivacySuggestions.BuildPrivacySuggestionsAsync(_wallet, _info, _destination, previous.Item1, _isFixedAmount, _cancellationTokenSource.Token);
}
});
+
+ ChangePocketCommand = ReactiveCommand.CreateFromTask(OnChangePocketsAsync);
}
public TransactionSummaryViewModel CurrentTransactionSummary { get; }
@@ -159,6 +157,8 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
public ICommand AdjustFeeCommand { get; }
+ public ICommand ChangePocketCommand { get; }
+
public ICommand UndoCommand { get; }
private async Task ShowAdvancedDialogAsync()
@@ -194,6 +194,7 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
}
_transaction = transaction;
+ CheckChangePocketAvailable(_transaction);
_currentTransactionInfo = _info.Clone();
}
@@ -329,7 +330,7 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
}
}
- private async Task<bool> TryHandleInsufficientBalanceCaseAsync(decimal differenceOfFeePercentage, Money targetAmount, BuildTransactionReason reason)
+ private async Task<bool> TryHandleInsufficientBalanceCaseAsync(decimal differenceOfFeePercentage, Money minimumRequiredAmount, BuildTransactionReason reason)
{
var maximumPossibleFeeRate =
TransactionFeeHelper.TryGetMaximumPossibleFeeRate(differenceOfFeePercentage, _wallet, _info.FeeRate, out var feeRate)
@@ -367,9 +368,10 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
else
{
var doSilentPocketSelection = reason == BuildTransactionReason.Initialization;
+ _info.MinimumRequiredAmount = minimumRequiredAmount;
var selectPocketsDialog =
- await NavigateDialogAsync(new PrivacyControlViewModel(_wallet, _info, usedCoins: _transaction?.SpentCoins, isSilent: doSilentPocketSelection, targetAmount: targetAmount));
+ await NavigateDialogAsync(new PrivacyControlViewModel(_wallet, _info, usedCoins: _transaction?.SpentCoins, isSilent: doSilentPocketSelection));
if (selectPocketsDialog.Kind == DialogResultKind.Normal && selectPocketsDialog.Result is { })
{
@@ -391,29 +393,13 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
return false;
}
- private async Task<bool> NavigateConfirmLabelsDialogAsync(BuildTransactionResult transaction)
- {
- var labels = SmartLabel.Merge(transaction.SpentCoins.Select(x => x.GetLabels(_wallet.KeyManager.MinAnonScoreTarget)));
- var suggestionViewModel = new PocketSuggestionViewModel(labels);
- var dialog = new ConfirmLabelsDialogViewModel(suggestionViewModel);
-
- return (await NavigateDialogAsync(dialog, NavigationTarget.CompactDialogScreen)).Result;
- }
-
private async Task InitialiseViewModelAsync()
{
if (await BuildTransactionAsync(BuildTransactionReason.Initialization) is { } initialTransaction)
{
UpdateTransaction(CurrentTransactionSummary, initialTransaction);
- var suggestionTask = PrivacySuggestions.BuildPrivacySuggestionsAsync(_wallet, _info, _destination, initialTransaction, _isFixedAmount, _cancellationTokenSource.Token);
-
- if (CurrentTransactionSummary.TransactionHasPockets && await NavigateConfirmLabelsDialogAsync(initialTransaction))
- {
- await OnChangePocketsAsync();
- }
-
- await suggestionTask;
+ await PrivacySuggestions.BuildPrivacySuggestionsAsync(_wallet, _info, _destination, initialTransaction, _isFixedAmount, _cancellationTokenSource.Token);
}
else
{
@@ -524,4 +510,15 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
CanUndo = true;
}
}
+
+ private void CheckChangePocketAvailable(BuildTransactionResult transaction)
+ {
+ var usedCoins = transaction.SpentCoins;
+ var pockets = _wallet.GetPockets().ToArray();
+ var amount = _info.MinimumRequiredAmount == Money.Zero ? _info.Amount : _info.MinimumRequiredAmount;
+ var labelSelection = new LabelSelectionViewModel(amount);
+ labelSelection.Reset(pockets);
+
+ _info.IsOtherPocketSelectionPossible = labelSelection.IsOtherSelectionPossible(usedCoins, _info.UserLabels);
+ }
}

remove dialog call and check change pocket availability