Skip to content

Commit 0838f21

Browse files
Merge pull request #1537 from VictoriousRaptor/FixProgramUID
[Dev][Program Plugin] Fix uid case of user disabled programs
2 parents e825a86 + a2c967d commit 0838f21

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ public override int GetHashCode()
277277
[Serializable]
278278
public class Application : IProgram
279279
{
280-
public string UniqueIdentifier { get; set; }
280+
private string _uid = string.Empty;
281+
public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); }
281282
public string DisplayName { get; set; }
282283
public string Description { get; set; }
283284
public string UserModelId { get; set; }

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
2323
public class Win32 : IProgram, IEquatable<Win32>
2424
{
2525
public string Name { get; set; }
26-
public string UniqueIdentifier { get => _uid; set => _uid = value.ToLowerInvariant(); } // For path comparison
26+
public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); } // For path comparison
2727
public string IcoPath { get; set; }
2828
public string FullPath { get; set; }
2929
public string LnkResolvedPath { get; set; }

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,39 @@ namespace Flow.Launcher.Plugin.Program.Views.Models
1515
/// </remarks>
1616
public class ProgramSource
1717
{
18-
private string name;
18+
private string name = string.Empty;
19+
private string loc = string.Empty;
20+
private string uniqueIdentifier = string.Empty;
1921

20-
private string loc;
2122
public string Location
2223
{
2324
get => loc;
2425
set
2526
{
26-
loc = value;
27-
UniqueIdentifier = value.ToLowerInvariant();
27+
loc = value ?? string.Empty;
28+
UniqueIdentifier = value;
2829
}
2930
}
30-
public string Name { get => name ?? new DirectoryInfo(Location).Name; set => name = value; }
31+
32+
public string Name { get => name; set => name = value ?? string.Empty; }
3133
public bool Enabled { get; set; } = true;
3234

33-
public string UniqueIdentifier { get; private set; }
35+
public string UniqueIdentifier
36+
{
37+
get => uniqueIdentifier;
38+
private set
39+
{
40+
uniqueIdentifier = value == null ? string.Empty : value.ToLowerInvariant();
41+
}
42+
}
3443

3544
[JsonConstructor]
3645
public ProgramSource(string name, string location, bool enabled, string uniqueIdentifier)
3746
{
38-
loc = location;
39-
this.name = name;
47+
loc = location ?? string.Empty;
48+
Name = name;
4049
Enabled = enabled;
41-
if (location.Equals(uniqueIdentifier, StringComparison.OrdinalIgnoreCase))
42-
{
43-
UniqueIdentifier = location.ToLowerInvariant(); // To make sure old config can be reset to case-insensitive
44-
}
45-
else
46-
{
47-
UniqueIdentifier = uniqueIdentifier; // For uwp apps
48-
}
50+
UniqueIdentifier = uniqueIdentifier;
4951
}
5052

5153
/// <summary>
@@ -55,14 +57,15 @@ public ProgramSource(string name, string location, bool enabled, string uniqueId
5557
/// <param name="enabled">enabled</param>
5658
public ProgramSource(string location, bool enabled = true)
5759
{
58-
loc = location;
60+
loc = location ?? string.Empty;
5961
Enabled = enabled;
60-
UniqueIdentifier = location.ToLowerInvariant(); // For path comparison
62+
UniqueIdentifier = location; // For path comparison
63+
Name = new DirectoryInfo(Location).Name;
6164
}
6265

6366
public ProgramSource(IProgram source)
6467
{
65-
loc = source.Location;
68+
loc = source.Location ?? string.Empty;
6669
Name = source.Name;
6770
Enabled = source.Enabled;
6871
UniqueIdentifier = source.UniqueIdentifier;

0 commit comments

Comments
 (0)