mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Flow.Launcher.Infrastructure;
|
|
using Flow.Launcher.Plugin;
|
|
using Flow.Launcher.ViewModel;
|
|
|
|
namespace Flow.Launcher.SettingPages.ViewModels;
|
|
|
|
public partial class SettingsPanePluginStoreViewModel : BaseModel
|
|
{
|
|
public string FilterText { get; set; } = string.Empty;
|
|
|
|
public IList<PluginStoreItemViewModel> ExternalPlugins =>
|
|
App.API.GetPluginManifest()?.Select(p => new PluginStoreItemViewModel(p))
|
|
.OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease)
|
|
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.RecentlyUpdated)
|
|
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.None)
|
|
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.Installed)
|
|
.ToList();
|
|
|
|
[RelayCommand]
|
|
private async Task RefreshExternalPluginsAsync()
|
|
{
|
|
if (await App.API.UpdatePluginManifestAsync())
|
|
{
|
|
OnPropertyChanged(nameof(ExternalPlugins));
|
|
}
|
|
}
|
|
|
|
public bool SatisfiesFilter(PluginStoreItemViewModel plugin)
|
|
{
|
|
return string.IsNullOrEmpty(FilterText) ||
|
|
App.API.FuzzySearch(FilterText, plugin.Name).IsSearchPrecisionScoreMet() ||
|
|
App.API.FuzzySearch(FilterText, plugin.Description).IsSearchPrecisionScoreMet();
|
|
}
|
|
}
|