mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Check result null & Improve docuements
This commit is contained in:
parent
c7de03bbec
commit
b52c7e756c
2 changed files with 21 additions and 8 deletions
|
|
@ -91,7 +91,7 @@ public class SearchWindowPluginHotkey : BasePluginHotkey
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// An action that will be executed when the hotkey is triggered.
|
||||
/// An action that will be executed when the hotkey is triggered and a result is selected.
|
||||
/// </summary>
|
||||
public Func<Result, bool> Action { get; set; } = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,15 +256,28 @@ internal static class HotKeyMapper
|
|||
existingCommand.Execute(null);
|
||||
}
|
||||
|
||||
foreach (var hotkeyModel in hotkeyModels)
|
||||
var selectedResult = _mainViewModel.Results.SelectedItem?.Result;
|
||||
// Check result nullability
|
||||
if (selectedResult != null)
|
||||
{
|
||||
var metadata = hotkeyModel.Metadata;
|
||||
if (metadata.Disabled)
|
||||
continue;
|
||||
var pluginId = selectedResult.PluginID;
|
||||
foreach (var hotkeyModel in hotkeyModels)
|
||||
{
|
||||
var metadata = hotkeyModel.Metadata;
|
||||
var pluginHotkey = hotkeyModel.PluginHotkey;
|
||||
|
||||
var pluginHotkey = hotkeyModel.PluginHotkey;
|
||||
if (pluginHotkey.Action?.Invoke(_mainViewModel.Results.SelectedItem?.Result) ?? false)
|
||||
App.API.HideMainWindow();
|
||||
// Check plugin ID match
|
||||
if (metadata.ID != pluginId)
|
||||
continue;
|
||||
|
||||
// Check plugin enabled state
|
||||
if (metadata.Disabled)
|
||||
continue;
|
||||
|
||||
// Invoke action
|
||||
if (pluginHotkey.Action?.Invoke(selectedResult) ?? false)
|
||||
App.API.HideMainWindow();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue