Remove DisabledProgramSource

This commit is contained in:
Vic 2022-10-28 18:06:44 +08:00
parent 6e19b49f91
commit 3efa0e185d
4 changed files with 9 additions and 29 deletions

View file

@ -192,9 +192,9 @@ namespace Flow.Launcher.Plugin.Program
if (_uwps.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
{
_uwps.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
.Enabled = false;
_settings.DisabledProgramSources.Add(new DisabledProgramSource(programToDelete));
var program = _uwps.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
program.Enabled = false;
_settings.DisabledProgramSources.Add(new ProgramSource(program));
_ = Task.Run(() =>
{
IndexUwpPrograms();
@ -203,9 +203,9 @@ namespace Flow.Launcher.Plugin.Program
}
else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
{
_win32s.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
.Enabled = false;
_settings.DisabledProgramSources.Add(new DisabledProgramSource(programToDelete));
var program = _win32s.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
program.Enabled = false;
_settings.DisabledProgramSources.Add(new ProgramSource(program));
_ = Task.Run(() =>
{
IndexWin32Programs();

View file

@ -9,7 +9,7 @@ namespace Flow.Launcher.Plugin.Program
{
public DateTime LastIndexTime { get; set; }
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>(); // For disabled single programs
public List<ProgramSource> DisabledProgramSources { get; set; } = new List<ProgramSource>(); // For disabled single programs
public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk"};
public bool EnableStartMenuSource { get; set; } = true;

View file

@ -14,7 +14,6 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands
// Even though these are disabled, we still want to display them so users can enable later on
return Main._settings
.DisabledProgramSources
.Select(s => new ProgramSource(s))
.Union(Main._settings.ProgramSources)
.ToList();
}
@ -62,8 +61,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands
var tmp = ProgramSetting.ProgramSettingDisplayList
.Where(t1 => !t1.Enabled
&& !Main._settings.DisabledProgramSources.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier)
&& !Main._settings.ProgramSources.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier))
.Select(x => new DisabledProgramSource(x));
&& !Main._settings.ProgramSources.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier));
Main._settings.DisabledProgramSources.AddRange(tmp);
}
@ -76,7 +74,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands
// .ForEach(t1 => t1.Enabled = true);
Main._settings.DisabledProgramSources
.RemoveAll(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && x.Enabled));
.RemoveAll(t1 => t1.Enabled);
}
internal static bool IsReindexRequired(this List<ProgramSource> selectedItems)

View file

@ -83,22 +83,4 @@ namespace Flow.Launcher.Plugin.Program.Views.Models
UniqueIdentifier = value.ToLowerInvariant(); // Update
}
}
public class DisabledProgramSource : ProgramSource
{
[JsonConstructor]
public DisabledProgramSource(string name, string location, bool enabled, string uniqueIdentifier) : base(name, location, enabled, uniqueIdentifier) { }
public DisabledProgramSource(string location) : base(location, false) { }
public DisabledProgramSource(ProgramSource source) : base(source)
{
Enabled = false;
}
public DisabledProgramSource(IProgram program) : base(program)
{
Enabled = false;
}
}
}