Skip to content

Commit

Permalink
Merge pull request #991 from molnard/feeformatsave
Browse files Browse the repository at this point in the history
making the feeratedisplay format non volatile
  • Loading branch information
nopara73 committed Dec 21, 2018
2 parents 6d2b41c + 072e413 commit 74805cc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,18 @@ public class SendTabViewModel : WalletActionViewModel
private const string BuildingTransactionButtonTextString = "Sending Transaction...";
private int _caretIndex;
private ObservableCollection<SuggestionViewModel> _suggestions;
private FeeDisplayFormat _feeDisplayFormat;

private bool IgnoreAmountChanges { get; set; }
private FeeDisplayFormat FeeDisplayFormat { get; set; }
private FeeDisplayFormat FeeDisplayFormat
{
get => _feeDisplayFormat;
set
{
_feeDisplayFormat = value;
Global.UiConfig.FeeDisplayFormat = (int)value;
}
}

public SendTabViewModel(WalletViewModel walletViewModel)
: base("Send", walletViewModel)
Expand All @@ -70,6 +80,7 @@ public SendTabViewModel(WalletViewModel walletViewModel)
ResetMax();
SetFeeTargetLimits();
FeeTarget = Global.UiConfig.FeeTarget ?? MinimumFeeTarget;
FeeDisplayFormat = (FeeDisplayFormat)(Enum.ToObject(typeof(FeeDisplayFormat), Global.UiConfig.FeeDisplayFormat) ?? FeeDisplayFormat.SatoshiPerByte);
SetFeesAndTexts();

Global.Synchronizer.PropertyChanged += Synchronizer_PropertyChanged;
Expand Down
14 changes: 13 additions & 1 deletion WalletWasabi.Gui/UiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Gui.Converters;
using WalletWasabi.Gui.Models;
using WalletWasabi.Helpers;
using WalletWasabi.Interfaces;
using WalletWasabi.JsonConverters;
Expand All @@ -31,6 +32,9 @@ public class UiConfig : IConfig
[JsonProperty(PropertyName = "FeeTarget")]
public int? FeeTarget { get; internal set; }

[JsonProperty(PropertyName = "FeeDisplayFormat")]
public int? FeeDisplayFormat { get; internal set; }

public UiConfig()
{
}
Expand All @@ -40,12 +44,13 @@ public UiConfig(string filePath)
SetFilePath(filePath);
}

public UiConfig(WindowState windowState, double height, double width, int feeTarget)
public UiConfig(WindowState windowState, double height, double width, int feeTarget,int feeDisplayFormat)
{
WindowState = Guard.NotNull(nameof(windowState), windowState);
Height = Guard.NotNull(nameof(height), height);
Width = Guard.NotNull(nameof(width), width);
FeeTarget = Guard.NotNull(nameof(feeTarget), feeTarget);
FeeDisplayFormat = Guard.NotNull(nameof(feeDisplayFormat), feeDisplayFormat);
}

/// <inheritdoc />
Expand All @@ -68,6 +73,7 @@ public async Task LoadOrCreateDefaultFileAsync()
Height = 530;
Width = 1100;
FeeTarget = 2;
FeeDisplayFormat = 0;

if (!File.Exists(FilePath))
{
Expand All @@ -90,6 +96,7 @@ public async Task LoadFileAsync()
Height = config.Height ?? Height;
Width = config.Width ?? Width;
FeeTarget = config.FeeTarget ?? FeeTarget;
FeeDisplayFormat = config.FeeDisplayFormat ?? FeeDisplayFormat;
}

/// <inheritdoc />
Expand Down Expand Up @@ -125,6 +132,11 @@ public async Task<bool> CheckFileChangeAsync()
return true;
}

if (FeeDisplayFormat != config.FeeDisplayFormat)
{
return true;
}

return false;
}

Expand Down

0 comments on commit 74805cc

Please sign in to comment.