[FindMyMouse]Fix duplicated settings path (#14584)

This commit is contained in:
Jaime Bernardo 2021-11-23 10:19:26 +00:00 committed by GitHub
parent 2d5276f742
commit 641d838140
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -9,7 +9,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{
public class FindMyMouseSettings : BasePTModuleSettings, ISettingsConfig
{
public const string ModuleName = "Find My Mouse";
public const string ModuleName = "FindMyMouse";
[JsonPropertyName("properties")]
public FindMyMouseProperties Properties { get; set; }

View File

@ -14,6 +14,24 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public MouseUtilsPage()
{
try
{
// By mistake, the first release of Find My Mouse was saving settings in two places at the same time.
// Delete the wrong path for Find My Mouse settings.
var tempSettingsUtils = new SettingsUtils();
if (tempSettingsUtils.SettingsExists("Find My Mouse"))
{
var settingsFilePath = tempSettingsUtils.GetSettingsFilePath("Find My Mouse");
System.IO.File.Delete(settingsFilePath);
tempSettingsUtils.DeleteSettings("Find My Mouse");
}
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (System.Exception)
#pragma warning restore CA1031 // Do not catch general exception types
{
}
var settingsUtils = new SettingsUtils();
ViewModel = new MouseUtilsViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), SettingsRepository<FindMyMouseSettings>.GetInstance(settingsUtils), SettingsRepository<MouseHighlighterSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;