Add notifications for settings that require restart
MODIFY
WalletWasabi.Fluent/Helpers/NotificationHelpers.cs
WalletWasabi.Fluent/Helpers/NotificationHelpers.cs
@@ -44,6 +44,11 @@ public static class NotificationHelpers
}
}
+ public static void Show(object viewModel)
+ {
+ NotificationManager?.Show(viewModel);
+ }
+
private static bool TryGetNotificationInputs(ProcessedResult result, [NotNullWhen(true)] out string? message)
{
message = null;

ADD
WalletWasabi.Fluent/ViewModels/SearchBar/Settings/RestartViewModel.cs
+using System.Reactive;
+using ReactiveUI;
+using WalletWasabi.Fluent.Helpers;
+
+namespace WalletWasabi.Fluent.ViewModels.SearchBar.Settings;
+
+public class RestartViewModel: ViewModelBase
+{
+ public string Message { get; }
+
+ public RestartViewModel(string message)
+ {
+ Message = message;
+ RestartCommand = ReactiveCommand.Create(AppLifetimeHelper.Restart);
+ }
+
+ public ReactiveCommand<Unit, Unit> RestartCommand { get; }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/SearchBar/Settings/Setting.cs
WalletWasabi.Fluent/ViewModels/SearchBar/Settings/Setting.cs
+using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Reactive;
using System.Reactive.Linq;
+using System.Windows.Input;
using ReactiveUI;
+using WalletWasabi.Fluent.Helpers;
namespace WalletWasabi.Fluent.ViewModels.SearchBar.Settings;
public class Setting<TTarget, TProperty> : ReactiveObject
{
- private TProperty _value;
+ private TProperty? _value;
- public Setting(TTarget target, Expression<Func<TTarget, TProperty>> selector)
+ public Setting([DisallowNull] TTarget target, Expression<Func<TTarget, TProperty>> selector, bool requiresRestart = false)
{
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+
+ if (selector == null)
+ {
+ throw new ArgumentNullException(nameof(selector));
+ }
+
if (selector == null)
{
throw new ArgumentNullException(nameof(selector));
@@ -21,7 +34,12 @@ public class Setting<TTarget, TProperty> : ReactiveObject
throw new InvalidOperationException("The expression {selector} is not a valid property selector");
}
- Value = (TProperty)pr.GetValue(target);
+ ShowRestartNotificationCommand = ReactiveCommand.Create(() =>
+ {
+ NotificationHelpers.Show(new RestartViewModel("To apply the new setting, Wasabi Wallet needs to be restarted"));
+ });
+
+ Value = (TProperty?)pr.GetValue(target);
SetIsActiveCommand = ReactiveCommand.Create(() => pr.SetValue(target, Value));
@@ -30,9 +48,20 @@ public class Setting<TTarget, TProperty> : ReactiveObject
.Skip(1)
.Select(_ => Unit.Default)
.InvokeCommand(SetIsActiveCommand);
+
+ if (requiresRestart)
+ {
+ this.WhenAnyValue(r => r.Value)
+ .Skip(1)
+ .Any()
+ .Select(_ => Unit.Default)
+ .InvokeCommand(ShowRestartNotificationCommand);
}
+ }
+
+ public ICommand ShowRestartNotificationCommand { get; set; }
- public TProperty Value
+ public TProperty? Value
{
get => _value;
set => this.RaiseAndSetIfChanged(ref _value, value);

MODIFY
WalletWasabi.Fluent/ViewModels/SearchBar/Sources/SettingsSource.cs
WalletWasabi.Fluent/ViewModels/SearchBar/Sources/SettingsSource.cs
@@ -22,8 +22,8 @@ public class SettingsSource : ISearchItemSource
new NonActionableSearchItem(new Setting<UiConfig, bool>(Services.UiConfig, b => b.AutoPaste), "Autopaste Bitcoin address", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
new NonActionableSearchItem(new Setting<UiConfig, bool>(Services.UiConfig, b => b.HideOnClose), "Hide on close", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
new NonActionableSearchItem(new Setting<UiConfig, bool>(Services.UiConfig, b => b.RunOnSystemStartup), "Run on system startup", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
- new NonActionableSearchItem(new Setting<Config, bool>(Services.Config, b => b.UseTor), "Use Tor", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
- new NonActionableSearchItem(new Setting<Config, bool>(Services.Config, b => b.TerminateTorOnExit), "Terminate Tor on exit", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
+ new NonActionableSearchItem(new Setting<Config, bool>(Services.Config, b => b.UseTor, true), "Use Tor", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
+ new NonActionableSearchItem(new Setting<Config, bool>(Services.Config, b => b.TerminateTorOnExit, true), "Terminate Tor on exit", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
new NonActionableSearchItem(new Setting<Config, bool>(Services.Config, b => b.StartLocalBitcoinCoreOnStartup), "Start local Bitcoin core on startup", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
new NonActionableSearchItem(new Setting<Config, bool>(Services.Config, b => b.StopLocalBitcoinCoreOnShutdown), "Start local Bitcoin core on shutdown", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },
new NonActionableSearchItem(new Setting<Config, bool>(Services.Config, b => b.JsonRpcServerEnabled), "Enable JSON-RPC Server", "Settings", new List<string>(), "nav_settings_regular") { IsDefault = false },

ADD
WalletWasabi.Fluent/Views/SearchBar/Settings/RestartView.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:settings="clr-namespace:WalletWasabi.Fluent.ViewModels.SearchBar.Settings"
+ mc:Ignorable="d"
+ x:DataType="settings:RestartViewModel"
+ x:CompileBindings="True"
+ x:Class="WalletWasabi.Fluent.Views.SearchBar.Settings.RestartView">
+ <DockPanel Margin="10">
+ <Button Classes="action" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Command="{Binding RestartCommand}">Restart now</Button>
+ <TextBlock Margin="20" TextAlignment="Center" TextWrapping="Wrap" Text="{Binding Message}" />
+ </DockPanel>
+</UserControl>

ADD
WalletWasabi.Fluent/Views/SearchBar/Settings/RestartView.axaml.cs
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace WalletWasabi.Fluent.Views.SearchBar.Settings;
+public partial class RestartView : UserControl
+{
+ public RestartView()
+ {
+ InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+}

Add notifications for settings that require restart