3
3
using System . IO ;
4
4
using System . Linq ;
5
5
using System . Text . Json . Serialization ;
6
+ using Windows . Foundation . Metadata ;
6
7
7
8
namespace Flow . Launcher . Plugin . Program
8
9
{
@@ -11,7 +12,10 @@ public class Settings
11
12
public DateTime LastIndexTime { get ; set ; }
12
13
public List < ProgramSource > ProgramSources { get ; set ; } = new List < ProgramSource > ( ) ;
13
14
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
15
19
public string [ ] CustomProtocols { get ; set ; } = Array . Empty < string > ( ) ;
16
20
17
21
public Dictionary < string , bool > BuiltinSuffixesStatus { get ; set ; } = new Dictionary < string , bool > {
@@ -32,6 +36,7 @@ public class Settings
32
36
33
37
public string [ ] GetSuffixes ( )
34
38
{
39
+ RemoveRedundantSuffixes ( ) ;
35
40
List < string > extensions = new List < string > ( ) ;
36
41
foreach ( var item in BuiltinSuffixesStatus )
37
42
{
@@ -84,6 +89,24 @@ public string[] GetProtocols()
84
89
}
85
90
}
86
91
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
+
87
110
public bool EnableStartMenuSource { get ; set ; } = true ;
88
111
public bool EnableDescription { get ; set ; } = false ;
89
112
public bool HideAppsPath { get ; set ; } = true ;
0 commit comments