mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
Refactoring CustomizedPluginConfig
1. Reorder the sequence of initialization of UserSettings. 2. Use dictionary for CustomizedPluginConfigs, so code logic like `.FirstOrDefault(o => o.ID == id);` are removed 3. part of #389
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Infrastructure.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Plugin;
|
||||
@@ -74,7 +72,7 @@ namespace Wox.Core.Plugin
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
// for plugins which doesn't has ActionKeywords key
|
||||
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> {metadata.ActionKeyword};
|
||||
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> { metadata.ActionKeyword };
|
||||
// for plugin still use old ActionKeyword
|
||||
metadata.ActionKeyword = metadata.ActionKeywords?[0];
|
||||
}
|
||||
@@ -100,14 +98,6 @@ namespace Wox.Core.Plugin
|
||||
return null;
|
||||
}
|
||||
|
||||
//replace action keyword if user customized it.
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID);
|
||||
if (customizedPluginConfig?.ActionKeywords?.Count > 0)
|
||||
{
|
||||
metadata.ActionKeywords = customizedPluginConfig.ActionKeywords;
|
||||
metadata.ActionKeyword = customizedPluginConfig.ActionKeywords[0];
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user