mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 11:39:16 +08:00
update plugins settings with changes (#10064)
This commit is contained in:
parent
e66db5cc10
commit
0c3f8af4d9
@ -75,10 +75,10 @@ namespace PowerLauncher
|
|||||||
|
|
||||||
var overloadSettings = _settingsUtils.GetSettingsOrDefault<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
|
var overloadSettings = _settingsUtils.GetSettingsOrDefault<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
|
||||||
|
|
||||||
if (overloadSettings.Plugins == null || !overloadSettings.Plugins.Any())
|
if (overloadSettings.Plugins == null || overloadSettings.Plugins.Count() != PluginManager.AllPlugins.Count)
|
||||||
{
|
{
|
||||||
// Needed to be consistent with old settings
|
// Needed to be consistent with old settings
|
||||||
overloadSettings.Plugins = GetDefaultPluginsSettings();
|
overloadSettings.Plugins = CombineWithDefaultSettings(overloadSettings.Plugins);
|
||||||
_settingsUtils.SaveSettings(overloadSettings.ToJsonString(), PowerLauncherSettings.ModuleName);
|
_settingsUtils.SaveSettings(overloadSettings.ToJsonString(), PowerLauncherSettings.ModuleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -173,6 +173,20 @@ namespace PowerLauncher
|
|||||||
return model.ToString();
|
return model.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<PowerLauncherPluginSettings> CombineWithDefaultSettings(IEnumerable<PowerLauncherPluginSettings> plugins)
|
||||||
|
{
|
||||||
|
var results = GetDefaultPluginsSettings().ToDictionary(x => x.Id);
|
||||||
|
foreach (var plugin in plugins)
|
||||||
|
{
|
||||||
|
if (results.ContainsKey(plugin.Id))
|
||||||
|
{
|
||||||
|
results[plugin.Id] = plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results.Values.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<PowerLauncherPluginSettings> GetDefaultPluginsSettings()
|
private static IEnumerable<PowerLauncherPluginSettings> GetDefaultPluginsSettings()
|
||||||
{
|
{
|
||||||
return PluginManager.AllPlugins.Select(x => new PowerLauncherPluginSettings()
|
return PluginManager.AllPlugins.Select(x => new PowerLauncherPluginSettings()
|
||||||
|
Loading…
Reference in New Issue
Block a user