Improve OnOpen exceptions
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -136,12 +136,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
base.OnOpen();
- if (Disposables != null)
- {
- throw new Exception("CoinJoin tab was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
TargetPrivacy = Global.Config.GetTargetPrivacy();

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -60,12 +60,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
base.OnOpen();
- if (Disposables != null)
- {
- throw new Exception("History Tab was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
Observable.FromEventPattern(Global.WalletService.Coins, nameof(Global.WalletService.Coins.CollectionChanged))
.Merge(Observable.FromEventPattern(Global.WalletService, nameof(Global.WalletService.NewBlockProcessed)))

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/PinPadViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/PinPadViewModel.cs
@@ -56,12 +56,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
base.OnOpen();
- if (Disposables != null)
- {
- throw new Exception("Pin Pad was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
}
public override bool OnClose()

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -135,12 +135,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
base.OnOpen();
- if (Disposables != null)
- {
- throw new Exception("Receive tab was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
Observable.FromEventPattern(Global.WalletService.Coins,
nameof(Global.WalletService.Coins.CollectionChanged))

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -1024,12 +1024,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override void OnOpen()
{
- if (Disposables != null)
- {
- throw new Exception("Send tab was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
Global.Synchronizer.WhenAnyValue(x => x.AllFeeEstimate).Subscribe(_ =>
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
@@ -142,12 +142,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override void OnOpen()
{
- if (Disposables != null)
- {
- throw new Exception("TransactionBroadcaster was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
base.OnOpen();
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
@@ -102,12 +102,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override void OnOpen()
{
- if (Disposables != null)
- {
- throw new Exception("Transaction Viewer was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
base.OnOpen();

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -161,12 +161,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public override void OnOpen()
{
- if (Disposables != null)
- {
- throw new Exception("WalletInfo was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
Closing = new CancellationTokenSource();

MODIFY
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
@@ -84,12 +84,7 @@ namespace WalletWasabi.Gui.Dialogs
public override void OnOpen()
{
- if (Disposables != null)
- {
- throw new Exception("Dialog was opened before last one closed (cannotclose)");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
CancelTokenSource = new CancellationTokenSource().DisposeWith(Disposables);

MODIFY
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
@@ -152,12 +152,7 @@ namespace WalletWasabi.Gui.Tabs
public override void OnOpen()
{
- if (Disposables != null)
- {
- throw new Exception("Settings was opened before last one closed.");
- }
-
- Disposables = new CompositeDisposable();
+ Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
Global.UiConfig.WhenAnyValue(x => x.LurkingWifeMode).Subscribe(_ =>
{

Improve OnOpen exceptions