Add reindex call for enable/disable button

For when program source enable && disable + where program not in cache
This commit is contained in:
Jeremy Wu
2019-10-15 22:39:55 +11:00
parent 44c1c93e81
commit 85638c23ae
4 changed files with 42 additions and 32 deletions

View File

@@ -27,6 +27,11 @@ namespace Wox.Plugin.Program.Views.Commands
// Even though these are disabled, we still want to display them so users can enable later on
Main._settings
.DisabledProgramSources
.Where(t1 => !Main._settings
.ProgramSources // program sourcces added above already, so exlcude
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
.Select(x => x)
.ToList()
.ForEach(x => list
.Add(
new ProgramSource
@@ -110,7 +115,7 @@ namespace Wox.Plugin.Program.Views.Commands
UniqueIdentifier = x.UniqueIdentifier,
Enabled = false
}
));
));
}
internal static void RemoveDisabledFromSettings(this List<ProgramSource> list)
@@ -125,5 +130,20 @@ namespace Wox.Plugin.Program.Views.Commands
.ToList()
.ForEach(x => Main._settings.DisabledProgramSources.Remove(x));
}
internal static bool IsReindexRequired(this List<ProgramSource> selectedItems)
{
if (selectedItems.Where(t1 => t1.Enabled && !Main._uwps.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0
&& selectedItems.Where(t1 => t1.Enabled && !Main._win32s.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0)
return true;
// Program Sources holds list of user added directories,
// so when we enable/disable we need to reindex to show/not show the programs
// that are found in those directories.
if (selectedItems.Where(t1 => Main._settings.ProgramSources.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0)
return true;
return false;
}
}
}