Update disable logic and add unique identifier for programs

This commit is contained in:
Jeremy Wu
2019-09-10 07:57:03 +10:00
parent 4a6242b3a0
commit 10fb76377c
7 changed files with 94 additions and 42 deletions

View File

@@ -160,7 +160,14 @@ namespace Wox.Plugin.Program.Programs
}
return u.Apps;
}).ToArray();
return applications;
var updatedListWithoutDisabledApps = applications
.Where(t1 => !Main._settings.ProgramSources
.Any(x => !x.Enabled
&& x.UniqueIdentifier == t1.UniqueIdentifier))
.Select(x => x);
return updatedListWithoutDisabledApps.ToArray();
}
else
{
@@ -202,20 +209,6 @@ namespace Wox.Plugin.Program.Programs
}
}
public static Application[] RetainApplications(Application[] applications, List<Settings.ProgramSource> applicationsToRetainPaths, bool enableProgramSourceOnly)
{
if(enableProgramSourceOnly)
return applications
.Where(t1 => applicationsToRetainPaths
.Any(x => x.Location == t1.Package.Location
&& x.Enabled))
.Select(t1 => t1).ToArray();
// Do not return if the application is disabled for indexing
return applications.Where(t1 => !applicationsToRetainPaths.Any(x => x.Location == t1.Package.Location && !x.Enabled))
.Select(t1 => t1).ToArray();
}
public override string ToString()
{
return FamilyName;
@@ -243,6 +236,7 @@ namespace Wox.Plugin.Program.Programs
public class Application : IProgram
{
public string AppListEntry { get; set; }
public string UniqueIdentifier { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public string UserModelId { get; set; }
@@ -337,6 +331,7 @@ namespace Wox.Plugin.Program.Programs
public Application(IAppxManifestApplication manifestApp, UWP package)
{
UserModelId = manifestApp.GetAppUserModelId();
UniqueIdentifier = manifestApp.GetAppUserModelId();
DisplayName = manifestApp.GetStringValue("DisplayName");
Description = manifestApp.GetStringValue("Description");
BackgroundColor = manifestApp.GetStringValue("BackgroundColor");