Fix blocking in autocopy
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -30,12 +30,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
RewriteTableAsync().GetAwaiter();
- this.WhenAnyValue(x => x.SelectedTransaction).Subscribe(transaction =>
+ this.WhenAnyValue(x => x.SelectedTransaction).Subscribe(async transaction =>
{
- if (Global.UiConfig.Autocopy is true)
- {
- transaction?.CopyToClipboard();
- }
+ if (Global.UiConfig.Autocopy is false || transaction is null) return;
+ await transaction.TryCopyTxIdToClipboardAsync();
});
SortCommand = ReactiveCommand.Create(() => RefreshOrdering());

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -79,12 +79,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
this.WhenAnyValue(x => x.Label).Subscribe(x => UpdateSuggestions(x));
- this.WhenAnyValue(x => x.SelectedAddress).Subscribe(address =>
+ this.WhenAnyValue(x => x.SelectedAddress).Subscribe(async address =>
{
- if (Global.UiConfig.Autocopy is true)
- {
- address?.CopyToClipboard();
- }
+ if (Global.UiConfig.Autocopy is false || address is null) return;
+ await address.TryCopyToClipboardAsync();
});
this.WhenAnyValue(x => x.CaretIndex).Subscribe(_ =>
@@ -98,14 +96,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
var isCoinListItemSelected = this.WhenAnyValue(x => x.SelectedAddress).Select(coin => coin != null);
- CopyAddress = ReactiveCommand.Create(() =>
- {
- try
+ CopyAddress = ReactiveCommand.Create(async () =>
{
- SelectedAddress?.CopyToClipboard();
- }
- catch (Exception)
- { }
+ if (SelectedAddress is null) return;
+ await SelectedAddress.TryCopyToClipboardAsync();
}, isCoinListItemSelected);
CopyLabel = ReactiveCommand.CreateFromTask(async () =>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewModel.cs
@@ -55,16 +55,16 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set => this.RaiseAndSetIfChanged(ref _clipboardNotificationOpacity, value);
}
- public void CopyToClipboard()
+ public async Task TryCopyTxIdToClipboardAsync()
{
- Application.Current.Clipboard.SetTextAsync(TransactionId).GetAwaiter().GetResult();
+ try
+ {
+ await Application.Current.Clipboard.SetTextAsync(TransactionId);
Interlocked.Increment(ref _copyNotificationsInprocess);
ClipboardNotificationVisible = true;
ClipboardNotificationOpacity = 1;
- Dispatcher.UIThread.PostLogException(async () =>
- {
try
{
await Task.Delay(1000);
@@ -82,7 +82,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
Interlocked.Decrement(ref _copyNotificationsInprocess);
}
- });
+ }
+ catch (Exception ex)
+ {
+ Logging.Logger.LogWarning<AddressViewModel>(ex);
+ }
}
}
}

MODIFY
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
@@ -83,16 +83,16 @@ namespace WalletWasabi.Gui.ViewModels
set => this.RaiseAndSetIfChanged(ref _qrCode, value);
}
- public void CopyToClipboard()
+ public async Task TryCopyToClipboardAsync()
{
- Application.Current.Clipboard.SetTextAsync(Address).GetAwaiter().GetResult();
+ try
+ {
+ await Application.Current.Clipboard.SetTextAsync(Address);
Interlocked.Increment(ref _copyNotificationsInprocess);
ClipboardNotificationVisible = true;
ClipboardNotificationOpacity = 1;
- Dispatcher.UIThread.PostLogException(async () =>
- {
try
{
await Task.Delay(1000);
@@ -110,7 +110,11 @@ namespace WalletWasabi.Gui.ViewModels
{
Interlocked.Decrement(ref _copyNotificationsInprocess);
}
- });
+ }
+ catch (Exception ex)
+ {
+ Logging.Logger.LogWarning<AddressViewModel>(ex);
+ }
}
#region IDisposable Support

Fix blocking in autocopy