Skip to content

Commit cc7d2bc

Browse files
Fix location setter and uid case
1 parent 3efa0e1 commit cc7d2bc

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
6363
}
6464
if (!update)
6565
{
66-
if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier.Equals(path, System.StringComparison.InvariantCultureIgnoreCase)))
66+
if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier.Equals(path, System.StringComparison.OrdinalIgnoreCase)))
6767
{
6868
var source = new ProgramSource(path);
6969
modified = true;
@@ -76,7 +76,7 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
7676
modified = _editing.Location != path || _editing.Enabled != Chkbox.IsChecked;
7777
if (modified)
7878
{
79-
_editing.SetLocation(path);
79+
_editing.Location = path;
8080
_editing.Enabled = Chkbox.IsChecked ?? true;
8181
}
8282
}

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

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ public class ProgramSource
1818
{
1919
private string name;
2020

21-
public string Location { get; private set; }
21+
private string loc;
22+
public string Location
23+
{
24+
get => loc;
25+
set
26+
{
27+
loc = value;
28+
UniqueIdentifier = value.ToLowerInvariant();
29+
}
30+
}
2231
public string Name { get => name ?? new DirectoryInfo(Location).Name; set => name = value; }
2332
public bool Enabled { get; set; } = true;
2433

@@ -27,35 +36,34 @@ public class ProgramSource
2736
[JsonConstructor]
2837
public ProgramSource(string name, string location, bool enabled, string uniqueIdentifier)
2938
{
30-
Location = location;
39+
loc = location;
3140
this.name = name;
3241
Enabled = enabled;
33-
UniqueIdentifier = uniqueIdentifier;
42+
if (location.Equals(uniqueIdentifier, StringComparison.OrdinalIgnoreCase))
43+
{
44+
UniqueIdentifier = location.ToLowerInvariant(); // To make sure old config can be reset to case-insensitive
45+
}
46+
else
47+
{
48+
UniqueIdentifier = uniqueIdentifier; // For uwp apps
49+
}
3450
}
3551

3652
/// <summary>
3753
/// Add source by location
3854
/// </summary>
3955
/// <param name="location">location of program source</param>
4056
/// <param name="enabled">enabled</param>
41-
public ProgramSource(string location, bool enabled=true)
57+
public ProgramSource(string location, bool enabled = true)
4258
{
43-
Location = location;
59+
loc = location;
4460
Enabled = enabled;
4561
UniqueIdentifier = location.ToLowerInvariant(); // For path comparison
4662
}
4763

48-
public ProgramSource(ProgramSource source)
49-
{
50-
Location = source.Location;
51-
Name = source.Name;
52-
Enabled = source.Enabled;
53-
UniqueIdentifier = source.UniqueIdentifier;
54-
}
55-
5664
public ProgramSource(IProgram source)
5765
{
58-
Location = source.Location;
66+
loc = source.Location;
5967
Name = source.Name;
6068
Enabled = source.Enabled;
6169
UniqueIdentifier = source.UniqueIdentifier;
@@ -75,12 +83,5 @@ public override int GetHashCode()
7583
{
7684
return HashCode.Combine(UniqueIdentifier);
7785
}
78-
79-
public void SetLocation(string value)
80-
{
81-
if (Location == value) return;
82-
Location = value;
83-
UniqueIdentifier = value.ToLowerInvariant(); // Update
84-
}
8586
}
8687
}

Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private void programSourceView_Drop(object sender, DragEventArgs e)
216216
foreach (string directory in directories)
217217
{
218218
if (Directory.Exists(directory)
219-
&& !ProgramSettingDisplayList.Any(x => x.UniqueIdentifier.Equals(directory, System.StringComparison.InvariantCultureIgnoreCase)))
219+
&& !ProgramSettingDisplayList.Any(x => x.UniqueIdentifier.Equals(directory, System.StringComparison.OrdinalIgnoreCase)))
220220
{
221221
var source = new ProgramSource(directory);
222222

0 commit comments

Comments
 (0)