legal docs viewmodels have no need to be so complex.. simply display a document thats it.
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/LegalDocumentsViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/LegalDocumentsViewModel.cs
-using ReactiveUI;
using WalletWasabi.Fluent.ViewModels.Navigation;
-using WalletWasabi.Legal;
-using WalletWasabi.Services;
-using System;
-using System.Reactive.Linq;
-using System.Reactive.Disposables;
namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
[NavigationMetaData(
- Title = "Legal Docs",
+ Title = "Terms and Conditions",
Caption = "Displays terms and conditions",
Order = 3,
Category = "General",
@@ -20,36 +14,10 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
[AutoNotify] private string? _content;
- public LegalDocumentsViewModel(LegalChecker legalChecker)
+ public LegalDocumentsViewModel(string content)
{
- Title = "Terms and Conditions";
+ Content = content;
NextCommand = BackCommand;
- LegalChecker = legalChecker;
-
- this.WhenAnyValue(x => x.Content)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(content => IsBusy = content is null);
- }
-
- public LegalChecker LegalChecker { get; }
-
- protected override void OnNavigatedTo(bool inStack, CompositeDisposable disposables)
- {
- base.OnNavigatedTo(inStack, disposables);
-
- Observable.Merge(
- Observable.FromEventPattern<LegalDocuments>(LegalChecker, nameof(LegalChecker.AgreedChanged)),
- Observable.FromEventPattern<LegalDocuments>(LegalChecker, nameof(LegalChecker.ProvisionalChanged)))
- .Select(x => x.EventArgs)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(legalDocuments => Content = legalDocuments.Content)
- .DisposeWith(disposables);
-
- Content = LegalChecker.TryGetNewLegalDocs(out LegalDocuments? provisional)
- ? provisional.Content
- : LegalChecker.CurrentLegalDocument is { } current
- ? current.Content
- : null;
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/TermsAndConditionsViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/TermsAndConditionsViewModel.cs
@@ -13,24 +13,13 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
[AutoNotify] private bool _isAgreed;
- public TermsAndConditionsViewModel(LegalChecker legalChecker)
+ public TermsAndConditionsViewModel(string legalDocument)
{
ViewTermsCommand = ReactiveCommand.Create(
- () =>
- {
- if (legalChecker.TryGetNewLegalDocs(out _))
- {
- var legalDocs = new LegalDocumentsViewModel(legalChecker);
- Navigate().To(legalDocs);
- }
- });
+ () => Navigate().To(new LegalDocumentsViewModel(legalDocument)));
- NextCommand = ReactiveCommand.CreateFromTask(
- async () =>
- {
- await legalChecker.AgreeAsync();
- Close(DialogResultKind.Normal, true);
- },
+ NextCommand = ReactiveCommand.Create(
+ () => Close(DialogResultKind.Normal, true),
this.WhenAnyValue(x => x.IsAgreed)
.ObserveOn(RxApp.MainThreadScheduler));
}

MODIFY
WalletWasabi.Fluent/ViewModels/Login/LoginViewModel.cs
WalletWasabi.Fluent/ViewModels/Login/LoginViewModel.cs
@@ -51,16 +51,17 @@ namespace WalletWasabi.Fluent.ViewModels.Login
if (!IsPasswordIncorrect)
{
- var legalChecker = (await NavigationManager.MaterialiseViewModel(LegalDocumentsViewModel.MetaData) as LegalDocumentsViewModel)?.LegalChecker;
+ var legalChecker = wallet.Synchronizer.LegalChecker;
- if (legalChecker is { } lc && lc.TryGetNewLegalDocs(out _))
+ if (legalChecker.TryGetNewLegalDocs(out var document))
{
- var legalDocs = new TermsAndConditionsViewModel(legalChecker);
+ var legalDocs = new TermsAndConditionsViewModel(document.Content);
var dialogResult = await NavigateDialog(legalDocs, NavigationTarget.DialogScreen);
- if (dialogResult.Result is { } accepted)
+ if (dialogResult.Result)
{
+ await legalChecker.AgreeAsync();
LoginWallet();
}
}

legal docs viewmodels have no need to be so complex.. simply display a document thats it.