mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Move PluginManifest public function to api
This commit is contained in:
parent
b9c0eb7b78
commit
55d1754ed6
5 changed files with 32 additions and 12 deletions
|
|
@ -344,5 +344,23 @@ namespace Flow.Launcher.Plugin
|
|||
/// Stop the loading bar in main window
|
||||
/// </summary>
|
||||
public void StopLoadingBar();
|
||||
|
||||
/// <summary>
|
||||
/// Update the plugin manifest
|
||||
/// </summary>
|
||||
/// <param name="usePrimaryUrlOnly">
|
||||
/// FL has multiple urls to download the plugin manifest. Set this to true to only use the primary url.
|
||||
/// </param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns>
|
||||
/// True if the manifest is updated successfully, false otherwise.
|
||||
/// </returns>
|
||||
public Task<bool> UpdatePluginManifestAsync(bool usePrimaryUrlOnly = false, CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// Get the plugin manifest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IReadOnlyList<UserPlugin> GetUserPlugins();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ using Flow.Launcher.Plugin.SharedCommands;
|
|||
using Flow.Launcher.ViewModel;
|
||||
using JetBrains.Annotations;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Core.ExternalPlugins;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
|
|
@ -354,6 +355,11 @@ namespace Flow.Launcher
|
|||
|
||||
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action cancelProgress = null) => ProgressBoxEx.ShowAsync(caption, reportProgressAsync, cancelProgress);
|
||||
|
||||
public Task<bool> UpdatePluginManifestAsync(bool usePrimaryUrlOnly = false, CancellationToken token = default) =>
|
||||
PluginsManifest.UpdateManifestAsync(usePrimaryUrlOnly, token);
|
||||
|
||||
public IReadOnlyList<UserPlugin> GetUserPlugins() => PluginsManifest.UserPlugins;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Flow.Launcher.Core.ExternalPlugins;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
|
@ -14,7 +13,7 @@ public partial class SettingsPanePluginStoreViewModel : BaseModel
|
|||
public string FilterText { get; set; } = string.Empty;
|
||||
|
||||
public IList<PluginStoreItemViewModel> ExternalPlugins =>
|
||||
PluginsManifest.UserPlugins?.Select(p => new PluginStoreItemViewModel(p))
|
||||
App.API.GetUserPlugins()?.Select(p => new PluginStoreItemViewModel(p))
|
||||
.OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease)
|
||||
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.RecentlyUpdated)
|
||||
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.None)
|
||||
|
|
@ -24,7 +23,7 @@ public partial class SettingsPanePluginStoreViewModel : BaseModel
|
|||
[RelayCommand]
|
||||
private async Task RefreshExternalPluginsAsync()
|
||||
{
|
||||
if (await PluginsManifest.UpdateManifestAsync())
|
||||
if (await App.API.UpdatePluginManifestAsync())
|
||||
{
|
||||
OnPropertyChanged(nameof(ExternalPlugins));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using System.Linq;
|
|||
using System.Windows.Controls;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Flow.Launcher.Core.ExternalPlugins;
|
||||
using Flow.Launcher.Plugin.PluginsManager.ViewModels;
|
||||
using Flow.Launcher.Plugin.PluginsManager.Views;
|
||||
|
||||
|
|
@ -34,7 +33,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
contextMenu = new ContextMenu(Context);
|
||||
pluginManager = new PluginsManager(Context, Settings);
|
||||
|
||||
await PluginsManifest.UpdateManifestAsync();
|
||||
await Context.API.UpdatePluginManifestAsync();
|
||||
}
|
||||
|
||||
public List<Result> LoadContextMenus(Result selectedResult)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Flow.Launcher.Core.ExternalPlugins;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -236,7 +235,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
internal async ValueTask<List<Result>> RequestUpdateAsync(string search, CancellationToken token,
|
||||
bool usePrimaryUrlOnly = false)
|
||||
{
|
||||
await PluginsManifest.UpdateManifestAsync(usePrimaryUrlOnly, token);
|
||||
await Context.API.UpdatePluginManifestAsync(usePrimaryUrlOnly, token);
|
||||
|
||||
var pluginFromLocalPath = null as UserPlugin;
|
||||
var updateFromLocalPath = false;
|
||||
|
|
@ -249,7 +248,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
}
|
||||
|
||||
var updateSource = !updateFromLocalPath
|
||||
? PluginsManifest.UserPlugins
|
||||
? Context.API.GetUserPlugins()
|
||||
: new List<UserPlugin> { pluginFromLocalPath };
|
||||
|
||||
var resultsForUpdate = (
|
||||
|
|
@ -601,7 +600,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
internal async ValueTask<List<Result>> RequestInstallOrUpdateAsync(string search, CancellationToken token,
|
||||
bool usePrimaryUrlOnly = false)
|
||||
{
|
||||
await PluginsManifest.UpdateManifestAsync(usePrimaryUrlOnly, token);
|
||||
await Context.API.UpdatePluginManifestAsync(usePrimaryUrlOnly, token);
|
||||
|
||||
if (Uri.IsWellFormedUriString(search, UriKind.Absolute)
|
||||
&& search.Split('.').Last() == ZipSuffix)
|
||||
|
|
@ -611,8 +610,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
return InstallFromLocalPath(search);
|
||||
|
||||
var results =
|
||||
PluginsManifest
|
||||
.UserPlugins
|
||||
Context.API.GetUserPlugins()
|
||||
.Where(x => !PluginExists(x.ID) && !PluginManager.PluginModified(x.ID))
|
||||
.Select(x =>
|
||||
new Result
|
||||
|
|
|
|||
Loading…
Reference in a new issue