add hotkey and interface listeners logic

This commit is contained in:
Jeremy 2022-02-15 22:15:04 +11:00
parent bf60f5d1a6
commit 1896b67989
3 changed files with 11 additions and 4 deletions

View file

@ -26,7 +26,6 @@ namespace Flow.Launcher.Core.Plugin
public static IPublicAPI API { private set; get; }
// todo happlebao, this should not be public, the indicator function should be embeded
public static PluginsSettings Settings;
private static List<PluginMetadata> _metadatas;
@ -181,9 +180,14 @@ namespace Flow.Launcher.Core.Plugin
public static async Task PublishPathSelectedFromResult(string selectedPath, string hotkey)
{
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
await Task.WhenAll(AllPlugins.Select(pluginPair => pluginPair.Plugin switch
{
IPathSelected p => p.PathSelected(selectedPath, hotkey),
IPathSelected p
when pluginPair
.Metadata
.Listeners
.Any(x => x.ContainsKey(hotkey) && x.ContainsValue("IPathSelected"))
=> p.PathSelected(selectedPath, hotkey),
_ => Task.CompletedTask,
}));
}

View file

@ -35,8 +35,10 @@ namespace Flow.Launcher.Plugin
public List<string> ActionKeywords { get; set; }
public List<Dictionary<string, string>> Listeners { get; set;}
public string IcoPath { get; set;}
public override string ToString()
{
return Name;

View file

@ -7,6 +7,7 @@
"*",
"*"
],
"Listeners": [{"f1": "IPathSelected"}],
"Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu",