1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
- using CommunityToolkit . Mvvm . Input ;
4
3
using Flow . Launcher . Core . Plugin ;
5
4
using Flow . Launcher . Infrastructure ;
6
5
using Flow . Launcher . Infrastructure . UserSettings ;
11
10
12
11
namespace Flow . Launcher . SettingPages . ViewModels ;
13
12
14
- public partial class SettingsPanePluginsViewModel : BaseModel
13
+ public class SettingsPanePluginsViewModel : BaseModel
15
14
{
16
15
private readonly Settings _settings ;
17
16
@@ -23,26 +22,23 @@ public SettingsPanePluginsViewModel(Settings settings)
23
22
public string FilterText { get ; set ; } = string . Empty ;
24
23
25
24
public PluginViewModel ? SelectedPlugin { get ; set ; }
25
+
26
26
private IEnumerable < PluginViewModel > ? _pluginViewModels ;
27
27
private IEnumerable < PluginViewModel > PluginViewModels => _pluginViewModels ??= PluginManager . AllPlugins
28
- . OrderBy ( x => x . Metadata . Disabled )
29
- . ThenBy ( y => y . Metadata . Name )
30
- . Select ( p => new PluginViewModel { PluginPair = p } )
28
+ . OrderBy ( plugin => plugin . Metadata . Disabled )
29
+ . ThenBy ( plugin => plugin . Metadata . Name )
30
+ . Select ( plugin => new PluginViewModel
31
+ {
32
+ PluginPair = plugin ,
33
+ PluginSettingsObject = _settings . PluginSettings . Plugins [ plugin . Metadata . ID ]
34
+ } )
31
35
. ToList ( ) ;
36
+
32
37
public List < PluginViewModel > FilteredPluginViewModels => PluginViewModels
33
38
. Where ( v =>
34
39
string . IsNullOrEmpty ( FilterText ) ||
35
40
StringMatcher . FuzzySearch ( FilterText , v . PluginPair . Metadata . Name ) . IsSearchPrecisionScoreMet ( ) ||
36
41
StringMatcher . FuzzySearch ( FilterText , v . PluginPair . Metadata . Description ) . IsSearchPrecisionScoreMet ( )
37
42
)
38
43
. ToList ( ) ;
39
-
40
- [ RelayCommand ]
41
- private void TogglePlugin ( )
42
- {
43
- if ( SelectedPlugin is null ) return ;
44
- var id = SelectedPlugin . PluginPair . Metadata . ID ;
45
- // used to sync the current status from the plugin manager into the setting to keep consistency after save
46
- _settings . PluginSettings . Plugins [ id ] . Disabled = SelectedPlugin . PluginPair . Metadata . Disabled ;
47
- }
48
44
}
0 commit comments