unsubscribe from event when wallet is detected
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/ConnectHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/ConnectHardwareWalletViewModel.cs
using System;
using System.Linq;
+using System.Reactive.Disposables;
using System.Timers;
using NBitcoin;
using ReactiveUI;
@@ -19,9 +20,6 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
{
WalletName = walletName;
HardwareWalletOperations = new HardwareWalletOperations(walletManager, network);
- HardwareWalletOperations.HardwareWalletsFound += OnHardwareWalletsFound;
- HardwareWalletOperations.SearchingHasNoResult += OnSearchingHasNoResult;
- HardwareWalletOperations.PassphraseTimer.Elapsed += OnPassphraseNeeded;
_message = "";
}
@@ -127,5 +125,21 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
throw new ArgumentOutOfRangeException(nameof(errorCode), errorCode, null);
}
}
+
+ protected override void OnNavigatedTo(bool inStack, CompositeDisposable disposable)
+ {
+ base.OnNavigatedTo(inStack, disposable);
+
+ HardwareWalletOperations.HardwareWalletsFound += OnHardwareWalletsFound;
+ HardwareWalletOperations.SearchingHasNoResult += OnSearchingHasNoResult;
+ HardwareWalletOperations.PassphraseTimer.Elapsed += OnPassphraseNeeded;
+
+ disposable.Add(Disposable.Create(() =>
+ {
+ HardwareWalletOperations.HardwareWalletsFound -= OnHardwareWalletsFound;
+ HardwareWalletOperations.SearchingHasNoResult -= OnSearchingHasNoResult;
+ HardwareWalletOperations.PassphraseTimer.Elapsed -= OnPassphraseNeeded;
+ }));
+ }
}
}

DELETE
WalletWasabi.Fluent/Views/AddWallet/HardwareWallet/DetectHardwareWalletView.axaml
-<UserControl xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
- xmlns:hardwareWallet="clr-namespace:WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet"
- mc:Ignorable="d"
- d:DesignWidth="600" d:DesignHeight="500"
- x:DataType="hardwareWallet:DetectHardwareWalletViewModel"
- x:CompileBindings="True"
- x:Class="WalletWasabi.Fluent.Views.AddWallet.HardwareWallet.DetectHardwareWalletView">
-
- <UserControl.Styles>
- <Style Selector="StackPanel.Delay">
- <Setter Property="Opacity" Value="0"/>
- <Style.Animations>
- <Animation Duration="0:0:30">
- <KeyFrame Cue="0%">
- <Setter Property="IsVisible" Value="False"/>
- </KeyFrame>
- <KeyFrame Cue="100%">
- <Setter Property="IsVisible" Value="True"/>
- </KeyFrame>
- </Animation>
- </Style.Animations>
- <Setter Property="Transitions">
- <Transitions>
- <DoubleTransition Property="Opacity" Duration="0:0:0.5" />
- </Transitions>
- </Setter>
- </Style>
- <Style Selector="StackPanel.Delay[IsVisible=True]">
- <Setter Property="Opacity" Value="1"/>
- </Style>
- </UserControl.Styles>
-
- <c:ContentArea Title="Hardware Wallet"
- IsBusy="{Binding IsBusy}"
- EnableCancel="True" CancelContent="Cancel"
- EnableBack="True"
- EnableNext="True" NextContent="Connect" >
-
- <DockPanel>
- <Button DockPanel.Dock="Bottom" HorizontalAlignment="Center" Classes="h8 plain activeHyperLink" Foreground="{DynamicResource SystemAccentColor}" Content="More information and help with Hardware Wallets" />
- <DockPanel>
- <StackPanel VerticalAlignment="Top" Spacing="40" DockPanel.Dock="Top" Margin="0 20 0 0">
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="40">
- <Image Height="100" Source="/Assets/HardwareIcons/ledger.png" />
- <Image Height="100" Source="/Assets/HardwareIcons/coldcard.png" />
- <Image Height="100" Source="/Assets/HardwareIcons/trezor.png" />
- <Image Height="100" Source="/Assets/HardwareIcons/generic.png" />
- </StackPanel>
- <TextBlock Text="Connect your Wallet to the USB Port on your PC and Login / Enter the PIN on the Wallet" HorizontalAlignment="Center" />
- </StackPanel>
- <c:ProgressRing IsIndeterminate="True" VerticalAlignment="Center" Height="100" Width="100" />
- </DockPanel>
- </DockPanel>
- </c:ContentArea>
-</UserControl>

DELETE
WalletWasabi.Fluent/Views/AddWallet/HardwareWallet/DetectHardwareWalletView.axaml.cs
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-
-namespace WalletWasabi.Fluent.Views.AddWallet.HardwareWallet
-{
- public class DetectHardwareWalletView : UserControl
- {
- public DetectHardwareWalletView()
- {
- InitializeComponent();
- }
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
- }
-}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/WalletWasabi.Fluent.csproj
WalletWasabi.Fluent/WalletWasabi.Fluent.csproj
<DependentUpon>DetectedHardwareWalletView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
- <Compile Update="Views\AddWallet\HardwareWallet\DetectHardwareWalletView.axaml.cs">
- <DependentUpon>DetectHardwareWalletView.axaml</DependentUpon>
- <SubType>Code</SubType>
- </Compile>
<Compile Update="Views\AddWallet\HardwareWallet\ConnectHardwareWalletView.axaml.cs">
<DependentUpon>ConnectHardwareWalletView.axaml</DependentUpon>
<SubType>Code</SubType>

unsubscribe from event when wallet is detected