Skip to content

Commit 3efa0e1

Browse files
Remove DisabledProgramSource
1 parent 6e19b49 commit 3efa0e1

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

Plugins/Flow.Launcher.Plugin.Program/Main.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ private static void DisableProgram(IProgram programToDelete)
192192

193193
if (_uwps.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
194194
{
195-
_uwps.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
196-
.Enabled = false;
197-
_settings.DisabledProgramSources.Add(new DisabledProgramSource(programToDelete));
195+
var program = _uwps.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
196+
program.Enabled = false;
197+
_settings.DisabledProgramSources.Add(new ProgramSource(program));
198198
_ = Task.Run(() =>
199199
{
200200
IndexUwpPrograms();
@@ -203,9 +203,9 @@ private static void DisableProgram(IProgram programToDelete)
203203
}
204204
else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
205205
{
206-
_win32s.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
207-
.Enabled = false;
208-
_settings.DisabledProgramSources.Add(new DisabledProgramSource(programToDelete));
206+
var program = _win32s.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier);
207+
program.Enabled = false;
208+
_settings.DisabledProgramSources.Add(new ProgramSource(program));
209209
_ = Task.Run(() =>
210210
{
211211
IndexWin32Programs();

Plugins/Flow.Launcher.Plugin.Program/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Settings
99
{
1010
public DateTime LastIndexTime { get; set; }
1111
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
12-
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>(); // For disabled single programs
12+
public List<ProgramSource> DisabledProgramSources { get; set; } = new List<ProgramSource>(); // For disabled single programs
1313
public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk"};
1414

1515
public bool EnableStartMenuSource { get; set; } = true;

Plugins/Flow.Launcher.Plugin.Program/Views/Commands/ProgramSettingDisplay.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ internal static List<ProgramSource> LoadProgramSources()
1414
// Even though these are disabled, we still want to display them so users can enable later on
1515
return Main._settings
1616
.DisabledProgramSources
17-
.Select(s => new ProgramSource(s))
1817
.Union(Main._settings.ProgramSources)
1918
.ToList();
2019
}
@@ -62,8 +61,7 @@ internal static void StoreDisabledInSettings()
6261
var tmp = ProgramSetting.ProgramSettingDisplayList
6362
.Where(t1 => !t1.Enabled
6463
&& !Main._settings.DisabledProgramSources.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier)
65-
&& !Main._settings.ProgramSources.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier))
66-
.Select(x => new DisabledProgramSource(x));
64+
&& !Main._settings.ProgramSources.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier));
6765

6866
Main._settings.DisabledProgramSources.AddRange(tmp);
6967
}
@@ -76,7 +74,7 @@ internal static void RemoveDisabledFromSettings()
7674
// .ForEach(t1 => t1.Enabled = true);
7775

7876
Main._settings.DisabledProgramSources
79-
.RemoveAll(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && x.Enabled));
77+
.RemoveAll(t1 => t1.Enabled);
8078
}
8179

8280
internal static bool IsReindexRequired(this List<ProgramSource> selectedItems)

Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,4 @@ public void SetLocation(string value)
8383
UniqueIdentifier = value.ToLowerInvariant(); // Update
8484
}
8585
}
86-
87-
public class DisabledProgramSource : ProgramSource
88-
{
89-
[JsonConstructor]
90-
public DisabledProgramSource(string name, string location, bool enabled, string uniqueIdentifier) : base(name, location, enabled, uniqueIdentifier) { }
91-
92-
public DisabledProgramSource(string location) : base(location, false) { }
93-
94-
public DisabledProgramSource(ProgramSource source) : base(source)
95-
{
96-
Enabled = false;
97-
}
98-
99-
public DisabledProgramSource(IProgram program) : base(program)
100-
{
101-
Enabled = false;
102-
}
103-
}
10486
}

0 commit comments

Comments
 (0)