@@ -14,16 +14,7 @@ export class VareSettingTab extends PluginSettingTab {
14
14
super ( app , plugin ) ;
15
15
this . plugin = plugin ;
16
16
17
- const manifests = Object . entries ( structuredClone ( this . plugin . app . plugins . manifests ) ) ;
18
- const pluginData = Object . entries ( this . plugin . settings . plugins ) ;
19
- this . pluginsList = manifests . map ( manifest => {
20
- const info : PluginInfo = { ...( manifest [ 1 ] as PluginManifest ) , repo : '' , releases : [ ] } ;
21
- const data = pluginData . filter ( data => data [ 0 ] === manifest [ 0 ] ) [ 0 ] ;
22
- if ( ! data ) {
23
- return info ;
24
- }
25
- return Object . assign ( info , data [ 1 ] ) ;
26
- } ) ;
17
+ this . loadPluginList ( ) ;
27
18
}
28
19
29
20
async display ( ) : Promise < void > {
@@ -92,6 +83,7 @@ export class VareSettingTab extends PluginSettingTab {
92
83
. setTooltip ( 'Reload plugins' )
93
84
. onClick ( ( ) => {
94
85
// Reload plugins
86
+ this . loadPluginList ( ) ;
95
87
this . display ( ) ;
96
88
} ) ) ;
97
89
@@ -239,4 +231,26 @@ export class VareSettingTab extends PluginSettingTab {
239
231
} ) ;
240
232
} ) ;
241
233
}
234
+
235
+ loadPluginList ( ) {
236
+ const manifests = Object . entries ( structuredClone ( this . plugin . app . plugins . manifests ) ) ;
237
+ const pluginData = Object . entries ( structuredClone ( this . plugin . settings . plugins ) ) ;
238
+
239
+ // Remove unused plugins
240
+ const upToDate = pluginData . filter ( data => ! manifests . every ( entry => data [ 0 ] !== entry [ 0 ] ) ) ;
241
+ this . plugin . settings . plugins = { } ;
242
+ upToDate . forEach ( plugin => {
243
+ this . plugin . settings . plugins [ plugin [ 0 ] ] = plugin [ 1 ] as PluginData ;
244
+ } ) ;
245
+
246
+ // Set plugin list
247
+ this . pluginsList = manifests . map ( manifest => {
248
+ const info : PluginInfo = { ...( manifest [ 1 ] as PluginManifest ) , repo : '' , releases : [ ] } ;
249
+ const data = upToDate . filter ( data => data [ 0 ] === manifest [ 0 ] ) [ 0 ] ;
250
+ if ( ! data ) {
251
+ return info ;
252
+ }
253
+ return Object . assign ( info , data [ 1 ] ) ;
254
+ } ) ;
255
+ }
242
256
}
0 commit comments