From 5c62c5ac9b999476d5bc2b18e475d40c8cae1ffb Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 15 Nov 2022 00:07:12 +0800 Subject: [PATCH 1/3] Fix disabled source --- .../Programs/UWP.cs | 3 +- .../Programs/Win32.cs | 2 +- .../Views/Models/ProgramSource.cs | 30 +++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 84aa93664..8a731f5b9 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -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; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index c13b32e80..6d27e579e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -23,7 +23,7 @@ namespace Flow.Launcher.Plugin.Program.Programs public class Win32 : IProgram, IEquatable { 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; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs index fb32fb892..e693aa471 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs @@ -16,36 +16,36 @@ namespace Flow.Launcher.Plugin.Program.Views.Models public class ProgramSource { private string name; + 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 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; + loc = location ?? string.Empty; this.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; } /// @@ -55,9 +55,9 @@ namespace Flow.Launcher.Plugin.Program.Views.Models /// enabled 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 } public ProgramSource(IProgram source) From 7f586b310655169c1470d32e3f01941dfc3f5f6f Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 15 Nov 2022 00:43:37 +0800 Subject: [PATCH 2/3] make name not null --- .../Views/Models/ProgramSource.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs index e693aa471..945825f83 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs @@ -15,7 +15,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Models /// public class ProgramSource { - private string name; + private string name = string.Empty; private string loc = string.Empty; private string uniqueIdentifier = string.Empty; @@ -29,7 +29,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Models } } - 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 => uniqueIdentifier; @@ -43,7 +43,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Models public ProgramSource(string name, string location, bool enabled, string uniqueIdentifier) { loc = location ?? string.Empty; - this.name = name; + Name = name; Enabled = enabled; UniqueIdentifier = uniqueIdentifier; } @@ -58,11 +58,12 @@ namespace Flow.Launcher.Plugin.Program.Views.Models loc = location ?? string.Empty; Enabled = enabled; 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; From 46b9565b85778fd9ab382a6b5001d660de2c8902 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 15 Nov 2022 00:48:24 +0800 Subject: [PATCH 3/3] formatting --- .../Views/Models/ProgramSource.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs index 945825f83..571dc0017 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs @@ -29,14 +29,16 @@ namespace Flow.Launcher.Plugin.Program.Views.Models } } - public string Name { get => name ; set => name = value ?? string.Empty; } + public string Name { get => name; set => name = value ?? string.Empty; } public bool Enabled { get; set; } = true; - public string UniqueIdentifier { get => uniqueIdentifier; + public string UniqueIdentifier + { + get => uniqueIdentifier; private set { uniqueIdentifier = value == null ? string.Empty : value.ToLowerInvariant(); - } + } } [JsonConstructor]