[skip ci] Add sync functions to UiConfig
MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -25,7 +25,7 @@ namespace WalletWasabi.Gui
var uiConfigFilePath = Path.Combine(Global.DataDir, "UiConfig.json");
var uiConfig = new UiConfig(uiConfigFilePath);
- await uiConfig.LoadOrCreateDefaultFileAsync();
+ uiConfig.LoadOrCreateDefaultFile();
Logger.LogInfo<UiConfig>("UiConfig is successfully initialized.");
Global.InitializeUiConfigs(uiConfig);

MODIFY
WalletWasabi.Gui/UiConfig.cs
WalletWasabi.Gui/UiConfig.cs
@@ -52,6 +52,17 @@ namespace WalletWasabi.Gui
Encoding.UTF8);
}
+ /// <inheritdoc />
+ public void ToFile()
+ {
+ AssertFilePathSet();
+
+ string jsonString = JsonConvert.SerializeObject(this, Formatting.Indented);
+ File.WriteAllText(FilePath,
+ jsonString,
+ Encoding.UTF8);
+ }
+
/// <inheritdoc />
public async Task LoadOrCreateDefaultFileAsync()
{
@@ -73,6 +84,27 @@ namespace WalletWasabi.Gui
await ToFileAsync();
}
+ /// <inheritdoc />
+ public void LoadOrCreateDefaultFile()
+ {
+ AssertFilePathSet();
+
+ WindowState = Avalonia.Controls.WindowState.Maximized;
+ Height = 530;
+ Width = 1100;
+
+ if (!File.Exists(FilePath))
+ {
+ Logging.Logger.LogInfo<Config>($"{nameof(Config)} file did not exist. Created at path: `{FilePath}`.");
+ }
+ else
+ {
+ LoadFile();
+ }
+
+ ToFile();
+ }
+
public async Task LoadFileAsync()
{
string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8);
@@ -83,6 +115,16 @@ namespace WalletWasabi.Gui
Width = config.Width ?? Width;
}
+ public void LoadFile()
+ {
+ string jsonString = File.ReadAllText(FilePath, Encoding.UTF8);
+ var config = JsonConvert.DeserializeObject<UiConfig>(jsonString);
+
+ WindowState = config.WindowState ?? WindowState;
+ Height = config.Height ?? Height;
+ Width = config.Width ?? Width;
+ }
+
/// <inheritdoc />
public async Task<bool> CheckFileChangeAsync()
{

[skip ci] Add sync functions to UiConfig