Remove Legaldocs from GUI
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -64,8 +64,7 @@ namespace WalletWasabi.Fluent.ViewModels
global.Config,
global.HostedServices,
global.BitcoinStore.SmartHeaderChain,
- global.Synchronizer,
- global.LegalDocuments);
+ global.Synchronizer);
_walletManager = new WalletManagerViewModel(global.WalletManager, global.UiConfig);

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -80,7 +80,7 @@ namespace WalletWasabi.Gui
try
{
SetTheme();
- var statusBarViewModel = new StatusBarViewModel(Global.DataDir, Global.Network, Global.Config, Global.HostedServices, Global.BitcoinStore.SmartHeaderChain, Global.Synchronizer, Global.LegalDocuments);
+ var statusBarViewModel = new StatusBarViewModel(Global.DataDir, Global.Network, Global.Config, Global.HostedServices, Global.BitcoinStore.SmartHeaderChain, Global.Synchronizer);
MainWindowViewModel.Instance = new MainWindowViewModel(Global.Network, Global.UiConfig, Global.WalletManager, statusBarViewModel, IoC.Get<IShell>());
await Global.InitializeNoWalletAsync(TerminateService);

MODIFY
WalletWasabi.Gui/Shell/Commands/HelpCommands.cs
WalletWasabi.Gui/Shell/Commands/HelpCommands.cs
@@ -72,17 +72,11 @@ namespace WalletWasabi.Gui.Shell.Commands
}
}));
- LegalDocumentsCommand = new CommandDefinition(
- "Legal Documents",
- commandIconService.GetCompletionKindImage("LegalDocuments"),
- ReactiveCommand.Create(() => IoC.Get<IShell>().AddOrSelectDocument(() => new LegalDocumentsViewModel(legalDoc: Locator.Current.GetService<Global>()?.LegalDocuments))));
-
Observable
.Merge(AboutCommand.GetReactiveCommand().ThrownExceptions)
.Merge(UserSupportCommand.GetReactiveCommand().ThrownExceptions)
.Merge(ReportBugCommand.GetReactiveCommand().ThrownExceptions)
.Merge(DocsCommand.GetReactiveCommand().ThrownExceptions)
- .Merge(LegalDocumentsCommand.GetReactiveCommand().ThrownExceptions)
.ObserveOn(RxApp.TaskpoolScheduler)
.Subscribe(ex =>
{
@@ -102,8 +96,5 @@ namespace WalletWasabi.Gui.Shell.Commands
[ExportCommandDefinition("Help.Documentation")]
public CommandDefinition DocsCommand { get; }
-
- [ExportCommandDefinition("Help.LegalDocuments")]
- public CommandDefinition LegalDocumentsCommand { get; }
}
}

DELETE
WalletWasabi.Gui/Tabs/LegalDocumentsView.xaml
-<UserControl xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:controls="clr-namespace:WalletWasabi.Gui.Controls;assembly=WalletWasabi.Gui"
- xmlns:converters="clr-namespace:WalletWasabi.Gui.Converters;assembly=WalletWasabi.Gui"
- x:Class="WalletWasabi.Gui.Tabs.LegalDocumentsView">
- <UserControl.Styles>
- <Style Selector="Button">
- <Setter Property="Foreground" Value="White" />
- <Setter Property="Background" Value="DarkGreen" />
- </Style>
- <Style Selector="Button > TextBlock">
- <Setter Property="Foreground" Value="White" />
- </Style>
- <Style Selector="Button:pointerover">
- <Setter Property="Background" Value="Green" />
- </Style>
- <Style Selector="Button:pressed /template/ ContentPresenter">
- <Setter Property="Background" Value="DarkGreen" />
- </Style>
- </UserControl.Styles>
- <Panel Background="{DynamicResource ThemeBackgroundBrush}">
- <TextBlock IsVisible="{Binding EmptyContent}" VerticalAlignment="Center" HorizontalAlignment="Center" Text="Text document is missing!" />
- <DockPanel LastChildFill="True" IsVisible="{Binding !EmptyContent}" Margin="10">
- <Grid ColumnDefinitions="*,320,*" DockPanel.Dock="Bottom" Margin="0 30 0 30">
- <Button Command="{Binding AgreeClicked}" Grid.Column="1" Grid.ColumnSpan="1" IsVisible="{Binding !IsAgreed}" Margin="0,10,0,0">I agree to the terms of service</Button>
- </Grid>
- <ScrollViewer HorizontalScrollBarVisibility="Disabled">
- <TextBlock Text="{Binding Text}" TextWrapping="Wrap" />
- </ScrollViewer>
- </DockPanel>
- </Panel>
-</UserControl>

DELETE
WalletWasabi.Gui/Tabs/LegalDocumentsView.xaml.cs
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-
-namespace WalletWasabi.Gui.Tabs
-{
- public class LegalDocumentsView : UserControl
- {
- public LegalDocumentsView()
- {
- InitializeComponent();
- }
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
- }
-}

DELETE
WalletWasabi.Gui/Tabs/LegalDocumentsViewModel.cs
-using Avalonia;
-using AvalonStudio.Documents;
-using AvalonStudio.Extensibility;
-using AvalonStudio.Shell;
-using ReactiveUI;
-using Splat;
-using System;
-using System.IO;
-using System.Reactive;
-using System.Reactive.Disposables;
-using System.Reactive.Linq;
-using System.Reactive.Threading.Tasks;
-using WalletWasabi.Gui.Controls.LockScreen;
-using WalletWasabi.Gui.Helpers;
-using WalletWasabi.Legal;
-
-namespace WalletWasabi.Gui.Tabs
-{
- public class LegalDocumentsViewModel : LockScreenViewModelBase, IDocumentTabViewModel
- {
- private string _text;
- private bool _emptyContent;
-
- public LegalDocumentsViewModel(string content = null, LegalDocuments legalDoc = null) : base()
- {
- FilePath = legalDoc?.FilePath;
- Content = content;
-
- LegalDoc = legalDoc;
- IsAgreed = content is null; // If content wasn't provided, then the filepath must had been provided. If the file exists, then it's agreed.
-
- AgreeClicked = ReactiveCommand.CreateFromTask(async () =>
- {
- IsAgreed = true;
- await LegalDoc.ToFileAsync(Content);
- Locator.Current.GetService<Global>().LegalDocuments = LegalDoc;
- Close();
- });
-
- AgreeClicked
- .ThrownExceptions
- .ObserveOn(RxApp.TaskpoolScheduler)
- .Subscribe(ex =>
- {
- Logging.Logger.LogError(ex);
- NotificationHelpers.Error(ex.ToUserFriendlyString());
- });
-
- this.WhenAnyValue(x => x.Text)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(text => EmptyContent = string.IsNullOrEmpty(text));
- }
-
- public string FilePath { get; set; } = null;
-
- public string Content { get; set; } = null;
-
- public bool EmptyContent
- {
- get => _emptyContent;
- set => this.RaiseAndSetIfChanged(ref _emptyContent, value);
- }
-
- public string Text
- {
- get => _text;
- set => this.RaiseAndSetIfChanged(ref _text, value);
- }
-
- public ReactiveCommand<Unit, Unit> AgreeClicked { get; }
- public LegalDocuments LegalDoc { get; }
-
- public bool IsAgreed { get; set; }
- public bool IsDirty { get; set; }
-
- public string Title => "Legal Documents";
-
- public bool OnClose()
- {
- Disposables?.Dispose();
- IoC.Get<IShell>().RemoveDocument(this);
- return true;
- }
-
- public void OnDeselected()
- {
- }
-
- public void OnOpen()
- {
- OnInitialize(Disposables);
- }
-
- public void OnSelected()
- {
- }
-
- protected override void OnInitialize(CompositeDisposable disposables)
- {
- base.OnInitialize(disposables);
-
- if (!string.IsNullOrWhiteSpace(Content))
- {
- Text = Content;
- }
- else if (!string.IsNullOrWhiteSpace(FilePath))
- {
- File.ReadAllTextAsync(FilePath)
- .ToObservable(RxApp.TaskpoolScheduler)
- .Take(1)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(
- x => Text = x,
- onError: ex => Logging.Logger.LogError(ex))
- .DisposeWith(disposables);
- }
- }
- }
-}

MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -46,11 +46,9 @@ namespace WalletWasabi.Gui.ViewModels
private ObservableAsPropertyHelper<string> _status;
private bool _downloadingBlock;
- private bool _legalDocsLoading;
-
private volatile bool _disposedValue = false; // To detect redundant calls
- public StatusBarViewModel(string dataDir, Network network, Config config, HostedServices hostedServices, SmartHeaderChain smartHeaderChain, WasabiSynchronizer synchronizer, LegalDocuments? legalDocuments)
+ public StatusBarViewModel(string dataDir, Network network, Config config, HostedServices hostedServices, SmartHeaderChain smartHeaderChain, WasabiSynchronizer synchronizer)
{
DataDir = dataDir;
Network = network;
@@ -58,7 +56,6 @@ namespace WalletWasabi.Gui.ViewModels
HostedServices = hostedServices;
SmartHeaderChain = smartHeaderChain;
Synchronizer = synchronizer;
- LegalDocuments = legalDocuments;
Backend = BackendStatus.NotConnected;
UseTor = false;
Tor = TorStatus.NotRunning;
@@ -89,8 +86,6 @@ namespace WalletWasabi.Gui.ViewModels
private SmartHeaderChain SmartHeaderChain { get; }
- private LegalDocuments? LegalDocuments { get; }
-
public bool UseBitcoinCore
{
get => _useBitcoinCore;
@@ -353,35 +348,6 @@ namespace WalletWasabi.Gui.ViewModels
UpdateAvailable = !x.ClientUpToDate;
CriticalUpdateAvailable = !x.BackendCompatible;
-
- if (!_legalDocsLoading)
- {
- _legalDocsLoading = true;
-
- try
- {
- if (LegalDocuments is null || LegalDocuments.Version < x.LegalDocumentsVersion)
- {
- WasabiClient client = Synchronizer.WasabiClientFactory.SharedWasabiClient;
- var versions = await client.GetVersionsAsync(CancellationToken.None);
- var version = versions.LegalDocumentsVersion;
- var legalFolderPath = Path.Combine(DataDir, LegalDocuments.LegalFolderName);
- var filePath = Path.Combine(legalFolderPath, $"{version}.txt");
- var legalContent = await client.GetLegalDocumentsAsync(CancellationToken.None);
-
- MainWindowViewModel.Instance.PushLockScreen(new LegalDocumentsViewModel(legalContent, new LegalDocuments(filePath)));
- }
- }
- catch (Exception ex)
- {
- Logger.LogError(ex);
- NotificationHelpers.Error($"Could not get Legal Documents!{(ex.InnerException is TorConnectionException ? " Backend not connected. Check your internet connection!" : "")}");
- }
- finally
- {
- _legalDocsLoading = false;
- }
- }
});
UpdateCommand = ReactiveCommand.CreateFromTask(async () =>

Remove Legaldocs from GUI