Skip to content

Commit a3a50cd

Browse files
Backward compatibilty
1 parent cc65562 commit a3a50cd

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Text.Json.Serialization;
6+
using Windows.Foundation.Metadata;
67

78
namespace Flow.Launcher.Plugin.Program
89
{
@@ -11,7 +12,10 @@ public class Settings
1112
public DateTime LastIndexTime { get; set; }
1213
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
1314
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();
14-
public string[] CustomSuffixes { get; set; } = Array.Empty<string>();
15+
16+
[Obsolete, JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
17+
public string[] ProgramSuffixes { get; set; } = null;
18+
public string[] CustomSuffixes { get; set; } = Array.Empty<string>(); // Custom suffixes only
1519
public string[] CustomProtocols { get; set; } = Array.Empty<string>();
1620

1721
public Dictionary<string, bool> BuiltinSuffixesStatus { get; set; } = new Dictionary<string, bool>{
@@ -32,6 +36,7 @@ public class Settings
3236

3337
public string[] GetSuffixes()
3438
{
39+
RemoveRedundantSuffixes();
3540
List<string> extensions = new List<string>();
3641
foreach (var item in BuiltinSuffixesStatus)
3742
{
@@ -84,6 +89,24 @@ public string[] GetProtocols()
8489
}
8590
}
8691

92+
private void RemoveRedundantSuffixes()
93+
{
94+
// Migrate to new settings
95+
// CustomSuffixes no longer contains custom suffixes
96+
// users has tweaked the settings
97+
// or this function has been executed once
98+
if (UseCustomSuffixes == true || ProgramSuffixes == null)
99+
return;
100+
var suffixes = ProgramSuffixes.ToList();
101+
foreach(var item in BuiltinSuffixesStatus)
102+
{
103+
suffixes.Remove(item.Key);
104+
}
105+
CustomSuffixes = suffixes.ToArray(); // Custom suffixes
106+
UseCustomSuffixes = CustomSuffixes.Length != 0; // Search custom suffixes or not
107+
ProgramSuffixes = null;
108+
}
109+
87110
public bool EnableStartMenuSource { get; set; } = true;
88111
public bool EnableDescription { get; set; } = false;
89112
public bool HideAppsPath { get; set; } = true;

0 commit comments

Comments
 (0)