cleanup, simplification
MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/Authorization/AuthorizationDialogBase.cs
WalletWasabi.Fluent/ViewModels/Dialogs/Authorization/AuthorizationDialogBase.cs
@@ -6,35 +6,27 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs.Authorization;
public abstract partial class AuthorizationDialogBase : DialogViewModelBase<bool>
{
- [AutoNotify] private string _errorMessage = "";
+ [AutoNotify] private bool _hasAuthorizationFailed;
+
+ [AutoNotify(SetterModifier = AccessModifier.Protected)]
+ private string _authorizationFailedMessage = "The Authorization has failed, please try again.";
protected AuthorizationDialogBase()
{
- NextCommand = ReactiveCommand.CreateFromTask(async () =>
- {
- var result = await AuthorizeCoreAsync();
- if (result)
- {
- Close(DialogResultKind.Normal, result);
- }
- });
+ NextCommand = ReactiveCommand.CreateFromTask(AuthorizeCoreAsync);
EnableAutoBusyOn(NextCommand);
}
- protected abstract string AuthorizationFailedMessage { get; }
-
protected abstract Task<bool> AuthorizeAsync();
- private async Task<bool> AuthorizeCoreAsync()
+ private async Task AuthorizeCoreAsync()
{
- var success = await AuthorizeAsync();
+ HasAuthorizationFailed = !await AuthorizeAsync();
- if (!success)
+ if (!HasAuthorizationFailed)
{
- ErrorMessage = AuthorizationFailedMessage;
+ Close(DialogResultKind.Normal, true);
}
-
- return success;
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/Authorization/HardwareWalletAuthDialogViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/Authorization/HardwareWalletAuthDialogViewModel.cs
@@ -29,6 +29,8 @@ public partial class HardwareWalletAuthDialogViewModel : AuthorizationDialogBase
SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);
EnableBack = false;
+
+ AuthorizationFailedMessage = $"Authorization failed.{Environment.NewLine}Please, check your device and try again.";
}
public WalletType WalletType { get; }
@@ -55,6 +57,4 @@ public partial class HardwareWalletAuthDialogViewModel : AuthorizationDialogBase
return false;
}
}
-
- protected override string AuthorizationFailedMessage => $"Authorization failed.{Environment.NewLine}Please, check your device and try again.";
}

MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/Authorization/PasswordAuthDialogViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/Authorization/PasswordAuthDialogViewModel.cs
@@ -23,22 +23,14 @@ public partial class PasswordAuthDialogViewModel : AuthorizationDialogBase
SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);
EnableBack = false;
- }
- protected override void OnDialogClosed()
- {
- Password = "";
+ AuthorizationFailedMessage = $"The password is incorrect.{Environment.NewLine}Please, try Again.";
}
- protected override string AuthorizationFailedMessage => $"The password is incorrect.{Environment.NewLine}Please, try Again.";
-
protected override async Task<bool> AuthorizeAsync()
{
var success = await Task.Run(() => PasswordHelper.TryPassword(_wallet.KeyManager, Password, out _));
- if (!success)
- {
Password = "";
- }
return success;
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -485,11 +485,6 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
var authDialog = AuthorizationHelpers.GetAuthorizationDialog(_wallet, transactionAuthorizationInfo);
var authDialogResult = await NavigateDialogAsync(authDialog, authDialog.DefaultTarget, NavigationMode.Clear);
- if (!authDialogResult.Result && authDialogResult.Kind == DialogResultKind.Normal)
- {
- await ShowErrorAsync("Authorization", "The Authorization has failed, please try again.", "");
- }
-
return authDialogResult.Result;
}

MODIFY
WalletWasabi.Fluent/Views/Dialogs/Authorization/HardwareWalletAuthDialogView.axaml
WalletWasabi.Fluent/Views/Dialogs/Authorization/HardwareWalletAuthDialogView.axaml
<Image Source="{Binding WalletType, Converter={x:Static conv:WalletIconConverter.WalletTypeToImage}}" />
</Viewbox>
<TextBlock TextAlignment="Center" Foreground="{StaticResource SystemErrorTextColor}"
- Text="{Binding ErrorMessage}"
+ Text="{Binding AuthorizationFailedMessage}"
TextWrapping="Wrap"
- IsVisible="{Binding ErrorMessage, Converter={x:Static ObjectConverters.IsNotNull}}" />
+ IsVisible="{Binding HasAuthorizationFailed}" />
</StackPanel>
</c:ContentArea>
</UserControl>

MODIFY
WalletWasabi.Fluent/Views/Dialogs/Authorization/PasswordAuthDialogView.axaml
WalletWasabi.Fluent/Views/Dialogs/Authorization/PasswordAuthDialogView.axaml
</TextBox>
<TextBlock TextAlignment="Center" Foreground="{StaticResource SystemErrorTextColor}"
TextWrapping="Wrap"
- Text="{Binding ErrorMessage}"
- IsVisible="{Binding ErrorMessage, Converter={x:Static ObjectConverters.IsNotNull}}" />
+ Text="{Binding AuthorizationFailedMessage}"
+ IsVisible="{Binding HasAuthorizationFailed}" />
</StackPanel>
</c:ContentArea>

cleanup, simplification