11using  System . Collections . Generic ; 
2+ using  System . Text . Json . Serialization ; 
23using  Flow . Launcher . Plugin ; 
34
45namespace  Flow . Launcher . Infrastructure . UserSettings 
@@ -27,17 +28,32 @@ public string NodeExecutablePath
2728            } 
2829        } 
2930
30-         private  Dictionary < string ,  Plugin >  Plugins  {  get ;  set ;  }  =  new ( ) ; 
31+         /// <summary> 
32+         /// Only used for serialization 
33+         /// </summary> 
34+         public  Dictionary < string ,  Plugin >  Plugins  {  get ;  set ;  }  =  new ( ) ; 
3135
36+         /// <summary> 
37+         /// Update plugin settings with metadata. 
38+         /// FL will get default values from metadata first and then load settings to metadata 
39+         /// </summary> 
40+         /// <param name="metadatas">Parsed plugin metadatas</param> 
3241        public  void  UpdatePluginSettings ( List < PluginMetadata >  metadatas ) 
3342        { 
3443            foreach  ( var  metadata  in  metadatas ) 
3544            { 
3645                if  ( Plugins . TryGetValue ( metadata . ID ,  out  var  settings ) ) 
3746                { 
47+                     // If settings exist, update settings & metadata value 
48+                     // update settings values with metadata 
3849                    if  ( string . IsNullOrEmpty ( settings . Version ) ) 
50+                     { 
3951                        settings . Version  =  metadata . Version ; 
52+                     } 
53+                     settings . DefaultActionKeywords  =  metadata . ActionKeywords ;  // metadata provides default values 
54+                     settings . DefaultSearchDelay  =  metadata . SearchDelay ;  // metadata provides default values 
4055
56+                     // update metadata values with settings 
4157                    if  ( settings . ActionKeywords ? . Count  >  0 ) 
4258                    { 
4359                        metadata . ActionKeywords  =  settings . ActionKeywords ; 
@@ -54,15 +70,18 @@ public void UpdatePluginSettings(List<PluginMetadata> metadatas)
5470                } 
5571                else 
5672                { 
73+                     // If settings does not exist, create a new one 
5774                    Plugins [ metadata . ID ]  =  new  Plugin 
5875                    { 
5976                        ID  =  metadata . ID , 
6077                        Name  =  metadata . Name , 
6178                        Version  =  metadata . Version , 
62-                         ActionKeywords  =  metadata . ActionKeywords , 
79+                         DefaultActionKeywords  =  metadata . ActionKeywords ,  // metadata provides default values 
80+                         ActionKeywords  =  metadata . ActionKeywords ,  // use default value 
6381                        Disabled  =  metadata . Disabled , 
6482                        Priority  =  metadata . Priority , 
65-                         SearchDelay  =  metadata . SearchDelay , 
83+                         DefaultSearchDelay  =  metadata . SearchDelay ,  // metadata provides default values 
84+                         SearchDelay  =  metadata . SearchDelay ,  // use default value 
6685                    } ; 
6786                } 
6887            } 
@@ -73,7 +92,7 @@ public Plugin GetPluginSettings(string id)
7392            if  ( Plugins . TryGetValue ( id ,  out  var  plugin ) ) 
7493            { 
7594                return  plugin ; 
76-     } 
95+              } 
7796            return  null ; 
7897        } 
7998
@@ -91,8 +110,18 @@ public class Plugin
91110        public  string  Name  {  get ;  set ;  } 
92111
93112        public  string  Version  {  get ;  set ;  } 
94-         public  List < string >  ActionKeywords  {  get ;  set ;  }  // a reference of the action keywords from plugin manager 
113+ 
114+         [ JsonIgnore ] 
115+         public  List < string >  DefaultActionKeywords  {  get ;  set ;  } 
116+ 
117+         // a reference of the action keywords from plugin manager 
118+         public  List < string >  ActionKeywords  {  get ;  set ;  } 
119+ 
95120        public  int  Priority  {  get ;  set ;  } 
121+ 
122+         [ JsonIgnore ] 
123+         public  int  DefaultSearchDelay  {  get ;  set ;  } 
124+ 
96125        public  int  SearchDelay  {  get ;  set ;  } 
97126
98127        /// <summary> 
0 commit comments