Skip to content

Commit

Permalink
Move CJ settings command to CoinJoinStateViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperJMN committed Mar 21, 2024
1 parent 290f4a4 commit 46a34fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
20 changes: 14 additions & 6 deletions WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Reactive;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
Expand All @@ -8,6 +7,7 @@
using WalletWasabi.Fluent.Models.UI;
using WalletWasabi.Fluent.Models.Wallets;
using WalletWasabi.Fluent.State;
using WalletWasabi.Fluent.ViewModels.Wallets.Settings;
using WalletWasabi.WabiSabi.Backend.Rounds;
using WalletWasabi.WabiSabi.Client.CoinJoinProgressEvents;
using WalletWasabi.WabiSabi.Client.StatusChangedEvents;
Expand Down Expand Up @@ -64,7 +64,7 @@ public partial class CoinJoinStateViewModel : ViewModelBase
private DateTimeOffset _countDownStartTime;
private DateTimeOffset _countDownEndTime;

public CoinJoinStateViewModel(UiContext uiContext, IWalletModel wallet, ReactiveCommand<Unit, Unit> navigateToCoinjoinSettingsCommand)
public CoinJoinStateViewModel(UiContext uiContext, IWalletModel wallet, WalletSettingsViewModel settings)
{
UiContext = uiContext;
_wallet = wallet;
Expand Down Expand Up @@ -152,9 +152,17 @@ public CoinJoinStateViewModel(UiContext uiContext, IWalletModel wallet, Reactive
_countdownTimer.Tick += (_, _) => _stateMachine.Fire(Trigger.Tick);

_stateMachine.Start();

CanNavigateToCoinjoinSettings = navigateToCoinjoinSettingsCommand.CanExecute;
NavigateToCoinjoinSettingsCommand = navigateToCoinjoinSettingsCommand;

var coinJoinSettingsCommand = ReactiveCommand.Create(
() =>
{
settings.SelectedTab = 1;
UiContext.Navigate(NavigationTarget.DialogScreen).To(settings);
},
Observable.Return(!_wallet.IsWatchOnlyWallet));

NavigateToSettingsCommand = coinJoinSettingsCommand;
CanNavigateToCoinjoinSettings = coinJoinSettingsCommand.CanExecute;

Check warning on line 165 in WalletWasabi.Fluent/ViewModels/Wallets/CoinJoinStateViewModel.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

❌ New issue: Large Method

CoinJoinStateViewModel has 78 lines, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
}

private enum State
Expand Down Expand Up @@ -183,7 +191,7 @@ private enum Trigger

public IObservable<bool> CanNavigateToCoinjoinSettings { get; }

public ICommand NavigateToCoinjoinSettingsCommand { get; }
public ICommand NavigateToSettingsCommand { get; }

public bool IsAutoCoinJoinEnabled => _wallet.Settings.AutoCoinjoin;

Expand Down
12 changes: 1 addition & 11 deletions WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,7 @@ public WalletViewModel(UiContext uiContext, IWalletModel walletModel, Wallet wal

WalletCoinsCommand = ReactiveCommand.Create(() => Navigate(NavigationTarget.DialogScreen).To().WalletCoins(WalletModel));

var coinJoinSettingsCommand = ReactiveCommand.Create(
() =>
{
Settings.SelectedTab = 1;
Navigate(NavigationTarget.DialogScreen).To(Settings);
},
Observable.Return(!WalletModel.IsWatchOnlyWallet));

CoinJoinSettingsCommand = coinJoinSettingsCommand;

CoinJoinStateViewModel = new CoinJoinStateViewModel(uiContext, WalletModel, coinJoinSettingsCommand);
CoinJoinStateViewModel = new CoinJoinStateViewModel(uiContext, WalletModel, Settings);

Tiles = GetTiles().ToList();

Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Fluent/Views/Wallets/MusicControlsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<Button Classes="plain" IsVisible="{Binding CanNavigateToCoinjoinSettings^}">
<Button.Flyout>
<MenuFlyout Placement="Top">
<MenuItem Header="Coinjoin Settings" Command="{Binding NavigateToCoinjoinSettingsCommand}">
<MenuItem Header="Coinjoin Settings" Command="{Binding NavigateToSettingsCommand}">
<MenuItem.Icon>
<PathIcon Data="{StaticResource settings_general_regular}" />
</MenuItem.Icon>
Expand Down

0 comments on commit 46a34fc

Please sign in to comment.