move `BuildPrivacySuggestionsAsync` logic
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionsFlyoutViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionsFlyoutViewModel.cs
using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
using ReactiveUI;
+using WalletWasabi.Blockchain.TransactionBuilding;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
@@ -8,6 +12,7 @@ public partial class PrivacySuggestionsFlyoutViewModel : ViewModelBase
[AutoNotify] private SuggestionViewModel? _previewSuggestion;
[AutoNotify] private SuggestionViewModel? _selectedSuggestion;
[AutoNotify] private bool _isOpen;
+ [AutoNotify] private bool _isLoading;
public PrivacySuggestionsFlyoutViewModel()
{
@@ -24,4 +29,25 @@ public partial class PrivacySuggestionsFlyoutViewModel : ViewModelBase
}
public ObservableCollection<SuggestionViewModel> Suggestions { get; }
+
+ public async Task BuildPrivacySuggestionsAsync(Wallet wallet, TransactionInfo info, BuildTransactionResult transaction)
+ {
+ IsLoading = true;
+
+ var (selected, suggestions) =
+ await ChangeAvoidanceSuggestionViewModel.GenerateSuggestionsAsync(info, wallet, transaction);
+
+
+ Suggestions.Clear();
+ SelectedSuggestion = null;
+
+ foreach (var suggestion in suggestions.Where(x => !x.IsOriginal))
+ {
+ Suggestions.Add(suggestion);
+ }
+
+ PreviewSuggestion = selected;
+
+ IsLoading = false;
+ }
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -30,7 +30,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
[AutoNotify] private bool _adjustFeeAvailable;
[AutoNotify] private bool _issuesTooltip;
[AutoNotify] private TransactionSummaryViewModel? _displayedTransactionSummary;
- [AutoNotify] private bool _isLoading;
public TransactionPreviewViewModel(Wallet wallet, TransactionInfo info)
{
@@ -188,30 +187,10 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
UpdateTransaction(CurrentTransactionSummary, newTransaction);
- await BuildPrivacySuggestionsAsync();
+ await PrivacySuggestions.BuildPrivacySuggestionsAsync(_wallet, _info, newTransaction);
}
}
- private async Task BuildPrivacySuggestionsAsync()
- {
- IsLoading = true;
- var (selected, suggestions) =
- await ChangeAvoidanceSuggestionViewModel.GenerateSuggestionsAsync(_info, _wallet,
- _transaction!);
-
- IsLoading = false;
-
- PrivacySuggestions.Suggestions.Clear();
- PrivacySuggestions.SelectedSuggestion = null;
-
- foreach (var suggestion in suggestions.Where(x => !x.IsOriginal))
- {
- PrivacySuggestions.Suggestions.Add(suggestion);
- }
-
- PrivacySuggestions.PreviewSuggestion = selected;
- }
-
private async Task OnChangePocketsAsync()
{
var selectPocketsDialog =
@@ -376,7 +355,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
UpdateTransaction(CurrentTransactionSummary, initialTransaction);
- await BuildPrivacySuggestionsAsync();
+ await PrivacySuggestions.BuildPrivacySuggestionsAsync(_wallet, _info, initialTransaction);
}
else
{

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/TransactionPreviewView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/TransactionPreviewView.axaml
ToolTip.Tip="Your privacy is being protected with PayJoin."
IsVisible="{Binding CurrentTransactionSummary.IsPayJoin}" />
- <c:ProgressRing Margin="10 0 10 5" Height="25" Width="25" IsIndeterminate="True" IsVisible="{Binding IsLoading}" />
+ <c:ProgressRing Margin="10 0 10 5" Height="25" Width="25" IsIndeterminate="True" IsVisible="{Binding PrivacySuggestions.IsLoading}" />
<Border Padding="10 0 10 10" Cursor="Hand" IsVisible="{Binding CurrentTransactionSummary.MaxPrivacy}">
<Interaction.Behaviors>
</FlyoutBase.AttachedFlyout>
<Panel.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
- <Binding Path="IsLoading" Converter="{x:Static BoolConverters.Not}"/>
+ <Binding Path="PrivacySuggestions.IsLoading" Converter="{x:Static BoolConverters.Not}"/>
<Binding Path="CurrentTransactionSummary.TransactionHasChange" />
<Binding Path="CurrentTransactionSummary.IsPayJoin" Converter="{x:Static BoolConverters.Not}" />
</MultiBinding>

move `BuildPrivacySuggestionsAsync` logic