attempt at saving stuff
MODIFY
WalletWasabi.Gui/Controls/SortingArrow.cs
WalletWasabi.Gui/Controls/SortingArrow.cs
@@ -12,23 +12,26 @@ using Avalonia.Styling;
using ReactiveUI;
using System;
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using System.Reactive.Linq;
using System.Runtime.CompilerServices;
namespace WalletWasabi.Gui.Controls
{
- public struct SortingPreference
+ public struct SortingPreference : IEquatable<SortingPreference>
{
public static SortingPreference DefaultValue = new SortingPreference(SortOrder.None, null);
- public SortingPreference(SortOrder sortOrder, string propertyTarget)
+ public SortingPreference(SortOrder sortOrder, Enum propertyTarget)
{
SortOrder = sortOrder;
PropertyTarget = propertyTarget;
}
public SortOrder SortOrder { get; set; }
- public string PropertyTarget { get; set; }
+ public Enum PropertyTarget { get; set; }
+
+ public bool Equals([AllowNull] SortingPreference other) => SortOrder == other.SortOrder && PropertyTarget == other.PropertyTarget;
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
@@ -23,6 +23,15 @@ using WalletWasabi.Wallets;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
+
+ internal enum CoinListViewSortTarget
+ {
+ Amount,
+ Privacy,
+ Clusters,
+ Status,
+ }
+
public class CoinListViewModel : ViewModelBase
{
private static HashSet<SmartCoinStatus> NotVisibleStatuses = new HashSet<SmartCoinStatus>()
@@ -62,6 +71,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
CanDequeueCoins = canDequeueCoins;
DisplayCommonOwnershipWarning = displayCommonOwnershipWarning;
+ SetSortOrder(Global.UiConfig.CoinListViewSortingPreference);
RefreshOrdering();
// Otherwise they're all selected as null on load.
@@ -86,51 +96,23 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
this.WhenAnyValue(x => x.AmountSortDirection)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(x =>
- {
- if (x != SortOrder.None)
- {
- PrivacySortDirection = SortOrder.None;
- StatusSortDirection = SortOrder.None;
- ClustersSortDirection = SortOrder.None;
- }
- });
+ .Where(x => x != SortOrder.None)
+ .Subscribe(x => SortColumn(x, CoinListViewSortTarget.Amount));
this.WhenAnyValue(x => x.ClustersSortDirection)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(x =>
- {
- if (x != SortOrder.None)
- {
- AmountSortDirection = SortOrder.None;
- StatusSortDirection = SortOrder.None;
- PrivacySortDirection = SortOrder.None;
- }
- });
+ .Where(x => x != SortOrder.None)
+ .Subscribe(x => SortColumn(x, CoinListViewSortTarget.Clusters));
this.WhenAnyValue(x => x.StatusSortDirection)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(x =>
- {
- if (x != SortOrder.None)
- {
- AmountSortDirection = SortOrder.None;
- PrivacySortDirection = SortOrder.None;
- ClustersSortDirection = SortOrder.None;
- }
- });
+ .Where(x => x != SortOrder.None)
+ .Subscribe(x => SortColumn(x, CoinListViewSortTarget.Status));
this.WhenAnyValue(x => x.PrivacySortDirection)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(x =>
- {
- if (x != SortOrder.None)
- {
- AmountSortDirection = SortOrder.None;
- StatusSortDirection = SortOrder.None;
- ClustersSortDirection = SortOrder.None;
- }
- });
+ .Where(x => x != SortOrder.None)
+ .Subscribe(x => SortColumn(x, CoinListViewSortTarget.Privacy));
SelectAllCheckBoxCommand = ReactiveCommand.Create(() =>
{
@@ -199,6 +181,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.Subscribe(ex => Logger.LogError(ex));
}
+ private void SortColumn(SortOrder x, CoinListViewSortTarget privacy)
+ {
+ Global.UiConfig.CoinListViewSortingPreference = new SortingPreference(x, privacy);
+ SetSortOrder(Global.UiConfig.CoinListViewSortingPreference);
+ }
+
public event EventHandler<SmartCoin> DequeueCoinsPressed;
public event EventHandler CoinListShown;
@@ -561,6 +549,17 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
isStrongPrivate);
}
+ private void SetSortOrder(SortingPreference sortPref)
+ {
+ var sortTarget = (CoinListViewSortTarget)sortPref.PropertyTarget;
+ var sortOrd = sortPref.SortOrder;
+
+ AmountSortDirection = sortTarget == CoinListViewSortTarget.Amount ? sortOrd : SortOrder.None;
+ PrivacySortDirection = sortTarget == CoinListViewSortTarget.Privacy ? sortOrd : SortOrder.None;
+ ClustersSortDirection = sortTarget == CoinListViewSortTarget.Clusters ? sortOrd : SortOrder.None;
+ StatusSortDirection = sortTarget == CoinListViewSortTarget.Status ? sortOrd : SortOrder.None;
+ }
+
public void OnClose()
{
foreach (var cvm in RootList.Items)

MODIFY
WalletWasabi.Gui/UiConfig.cs
WalletWasabi.Gui/UiConfig.cs
@@ -102,11 +102,7 @@ namespace WalletWasabi.Gui
set => RaiseAndSetIfChanged(ref _lockScreenPinHash, value);
}
- [JsonProperty(PropertyName = "CoinListViewSortingPreference", DefaultValueHandling = DefaultValueHandling.Ignore)]
- public SortingPreference CoinListViewSortingPreference
- {
- get => _coinListViewSortingPreference;
- set => RaiseAndSetIfChanged(ref _coinListViewSortingPreference, value);
- }
+ [JsonProperty(PropertyName = "CoinListViewSortingPreference")]
+ public SortingPreference CoinListViewSortingPreference { get; internal set; } = new SortingPreference(SortOrder.Increasing, default(SortOrder));
}
}

attempt at saving stuff