add exclude index search confirmation and persist settings to storage

This commit is contained in:
Jeremy Wu 2020-06-03 22:00:18 +10:00
parent 06877ca06b
commit b90664d760
2 changed files with 15 additions and 2 deletions

View file

@ -7,8 +7,8 @@ using System.Windows;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Plugin.Explorer.Search;
using System.Windows.Media;
using System.Linq;
using System.Reflection;
namespace Flow.Launcher.Plugin.Explorer
{
@ -188,13 +188,25 @@ namespace Flow.Launcher.Plugin.Explorer
{
return new Result
{
Title = "Exclude path from index search",
Title = "Exclude current and sub-directories from index search",
SubTitle = "Path: " + record.FullPath,
Action = _ =>
{
if(!Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x == record.FullPath))
Main.Settings.IndexSearchExcludedSubdirectoryPaths.Add(record.FullPath);
var pluginDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location.ToString());
var iconPath = pluginDirectory + "\\" + Constants.ExplorerIconImagePath;
Task.Run(() =>
{
Main.Context.API.ShowMsg("Excluded from Index Search", "Path: " + record.FullPath, iconPath);
// so the new path can be persisted to storage and not wait till next ViewModel save.
Main.Context.API.SaveAppAllSettings();
});
return false;
},
IcoPath = Constants.ExcludeFromIndexImagePath

View file

@ -12,6 +12,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal const string CopyImagePath = "Images\\copy.png";
internal const string IndexImagePath = "Images\\index.png";
internal const string ExcludeFromIndexImagePath = "Images\\excludeindexpath.png";
internal const string ExplorerIconImagePath = "Images\\explorer.png";
internal const string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";