Merge pull request #1537 from VictoriousRaptor/FixProgramUID

[Dev][Program Plugin] Fix uid case of user disabled programs
This commit is contained in:
VictoriousRaptor 2022-11-15 06:00:43 +08:00 committed by GitHub
commit 0838f21d40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 21 deletions

View file

@ -277,7 +277,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
[Serializable]
public class Application : IProgram
{
public string UniqueIdentifier { get; set; }
private string _uid = string.Empty;
public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); }
public string DisplayName { get; set; }
public string Description { get; set; }
public string UserModelId { get; set; }

View file

@ -23,7 +23,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
public class Win32 : IProgram, IEquatable<Win32>
{
public string Name { get; set; }
public string UniqueIdentifier { get => _uid; set => _uid = value.ToLowerInvariant(); } // For path comparison
public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); } // For path comparison
public string IcoPath { get; set; }
public string FullPath { get; set; }
public string LnkResolvedPath { get; set; }

View file

@ -15,37 +15,39 @@ namespace Flow.Launcher.Plugin.Program.Views.Models
/// </remarks>
public class ProgramSource
{
private string name;
private string name = string.Empty;
private string loc = string.Empty;
private string uniqueIdentifier = string.Empty;
private string loc;
public string Location
{
get => loc;
set
{
loc = value;
UniqueIdentifier = value.ToLowerInvariant();
loc = value ?? string.Empty;
UniqueIdentifier = value;
}
}
public string Name { get => name ?? new DirectoryInfo(Location).Name; set => name = value; }
public string Name { get => name; set => name = value ?? string.Empty; }
public bool Enabled { get; set; } = true;
public string UniqueIdentifier { get; private set; }
public string UniqueIdentifier
{
get => uniqueIdentifier;
private set
{
uniqueIdentifier = value == null ? string.Empty : value.ToLowerInvariant();
}
}
[JsonConstructor]
public ProgramSource(string name, string location, bool enabled, string uniqueIdentifier)
{
loc = location;
this.name = name;
loc = location ?? string.Empty;
Name = name;
Enabled = enabled;
if (location.Equals(uniqueIdentifier, StringComparison.OrdinalIgnoreCase))
{
UniqueIdentifier = location.ToLowerInvariant(); // To make sure old config can be reset to case-insensitive
}
else
{
UniqueIdentifier = uniqueIdentifier; // For uwp apps
}
UniqueIdentifier = uniqueIdentifier;
}
/// <summary>
@ -55,14 +57,15 @@ namespace Flow.Launcher.Plugin.Program.Views.Models
/// <param name="enabled">enabled</param>
public ProgramSource(string location, bool enabled = true)
{
loc = location;
loc = location ?? string.Empty;
Enabled = enabled;
UniqueIdentifier = location.ToLowerInvariant(); // For path comparison
UniqueIdentifier = location; // For path comparison
Name = new DirectoryInfo(Location).Name;
}
public ProgramSource(IProgram source)
{
loc = source.Location;
loc = source.Location ?? string.Empty;
Name = source.Name;
Enabled = source.Enabled;
UniqueIdentifier = source.UniqueIdentifier;