[Settings] Update version in General Settings (#2601)

* Update version in General Settings

* Set version in settings.json file

* Only overwrite the settings.json file if it is newer than the old version.

* Fix tests

* Fix test names and added comment
This commit is contained in:
Tomas Agustin Raies
2020-05-04 14:40:32 -07:00
committed by GitHub
parent d401474981
commit 7fc140af01
13 changed files with 174 additions and 46 deletions

View File

@@ -10,6 +10,8 @@ using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using Windows.Data.Html;
using Windows.System;
using Windows.UI.Popups;
using Windows.UI.Xaml;
@@ -32,6 +34,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
try
{
GeneralSettingsConfigs = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
if (Helper.CompareVersions(GeneralSettingsConfigs.PowertoysVersion, Helper.GetProductVersion()) < 0)
{
// Update settings
GeneralSettingsConfigs.PowertoysVersion = Helper.GetProductVersion();
SettingsUtils.SaveSettings(GeneralSettingsConfigs.ToJsonString(), string.Empty);
}
}
catch (FormatException e)
{
// If there is an issue with the version number format, don't migrate settings.
Debug.WriteLine(e.Message);
}
catch
{
@@ -216,6 +230,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public string PowerToysVersion
{
get
{
return Helper.GetProductVersion();
}
}
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
// Notify UI of property change