Resolve undisposed warning
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/Create/ConfirmRecoveryWordsViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/Create/ConfirmRecoveryWordsViewModel.cs
@@ -17,19 +17,20 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.Create;
public partial class ConfirmRecoveryWordsViewModel : RoutableViewModel
{
private readonly ReadOnlyObservableCollection<RecoveryWordViewModel> _confirmationWords;
+ private SourceList<RecoveryWordViewModel> _confirmationWordsSourceList;
[AutoNotify] private bool _isSkipEnable;
public ConfirmRecoveryWordsViewModel(List<RecoveryWordViewModel> mnemonicWords, KeyManager keyManager)
{
- var confirmationWordsSourceList = new SourceList<RecoveryWordViewModel>();
+ _confirmationWordsSourceList = new SourceList<RecoveryWordViewModel>();
_isSkipEnable = Services.WalletManager.Network != Network.Main || System.Diagnostics.Debugger.IsAttached;
var nextCommandCanExecute =
- confirmationWordsSourceList
+ _confirmationWordsSourceList
.Connect()
.ObserveOn(RxApp.MainThreadScheduler)
.WhenValueChanged(x => x.IsConfirmed)
- .Select(_ => confirmationWordsSourceList.Items.All(x => x.IsConfirmed));
+ .Select(_ => _confirmationWordsSourceList.Items.All(x => x.IsConfirmed));
EnableBack = true;
@@ -42,7 +43,7 @@ public partial class ConfirmRecoveryWordsViewModel : RoutableViewModel
CancelCommand = ReactiveCommand.Create(OnCancel);
- confirmationWordsSourceList
+ _confirmationWordsSourceList
.Connect()
.ObserveOn(RxApp.MainThreadScheduler)
.OnItemAdded(x => x.Reset())
@@ -51,7 +52,7 @@ public partial class ConfirmRecoveryWordsViewModel : RoutableViewModel
.Subscribe();
// Select random words to confirm.
- confirmationWordsSourceList.AddRange(mnemonicWords.OrderBy(_ => new Random().NextDouble()).Take(3));
+ _confirmationWordsSourceList.AddRange(mnemonicWords.OrderBy(_ => new Random().NextDouble()).Take(3));
}
public ReadOnlyObservableCollection<RecoveryWordViewModel> ConfirmationWords => _confirmationWords;
@@ -73,4 +74,13 @@ public partial class ConfirmRecoveryWordsViewModel : RoutableViewModel
var enableCancel = Services.WalletManager.HasWallet();
SetupCancel(enableCancel: false, enableCancelOnEscape: enableCancel, enableCancelOnPressed: false);
}
+
+ protected override void OnNavigatedFrom(bool isInHistory)
+ {
+ base.OnNavigatedFrom(isInHistory);
+ if (!isInHistory)
+ {
+ _confirmationWordsSourceList.Dispose();
+ }
+ }
}

Resolve undisposed warning