Skip to content

Commit 55d1754

Browse files
committed
Move PluginManifest public function to api
1 parent b9c0eb7 commit 55d1754

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,5 +344,23 @@ public interface IPublicAPI
344344
/// Stop the loading bar in main window
345345
/// </summary>
346346
public void StopLoadingBar();
347+
348+
/// <summary>
349+
/// Update the plugin manifest
350+
/// </summary>
351+
/// <param name="usePrimaryUrlOnly">
352+
/// FL has multiple urls to download the plugin manifest. Set this to true to only use the primary url.
353+
/// </param>
354+
/// <param name="token"></param>
355+
/// <returns>
356+
/// True if the manifest is updated successfully, false otherwise.
357+
/// </returns>
358+
public Task<bool> UpdatePluginManifestAsync(bool usePrimaryUrlOnly = false, CancellationToken token = default);
359+
360+
/// <summary>
361+
/// Get the plugin manifest
362+
/// </summary>
363+
/// <returns></returns>
364+
public IReadOnlyList<UserPlugin> GetUserPlugins();
347365
}
348366
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
using Flow.Launcher.ViewModel;
2929
using JetBrains.Annotations;
3030
using Flow.Launcher.Core.Resource;
31+
using Flow.Launcher.Core.ExternalPlugins;
3132

3233
namespace Flow.Launcher
3334
{
@@ -354,6 +355,11 @@ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", M
354355

355356
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action cancelProgress = null) => ProgressBoxEx.ShowAsync(caption, reportProgressAsync, cancelProgress);
356357

358+
public Task<bool> UpdatePluginManifestAsync(bool usePrimaryUrlOnly = false, CancellationToken token = default) =>
359+
PluginsManifest.UpdateManifestAsync(usePrimaryUrlOnly, token);
360+
361+
public IReadOnlyList<UserPlugin> GetUserPlugins() => PluginsManifest.UserPlugins;
362+
357363
#endregion
358364

359365
#region Private Methods

Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginStoreViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Linq;
33
using System.Threading.Tasks;
44
using CommunityToolkit.Mvvm.Input;
5-
using Flow.Launcher.Core.ExternalPlugins;
65
using Flow.Launcher.Infrastructure;
76
using Flow.Launcher.Plugin;
87
using Flow.Launcher.ViewModel;
@@ -14,7 +13,7 @@ public partial class SettingsPanePluginStoreViewModel : BaseModel
1413
public string FilterText { get; set; } = string.Empty;
1514

1615
public IList<PluginStoreItemViewModel> ExternalPlugins =>
17-
PluginsManifest.UserPlugins?.Select(p => new PluginStoreItemViewModel(p))
16+
App.API.GetUserPlugins()?.Select(p => new PluginStoreItemViewModel(p))
1817
.OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease)
1918
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.RecentlyUpdated)
2019
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.None)
@@ -24,7 +23,7 @@ public partial class SettingsPanePluginStoreViewModel : BaseModel
2423
[RelayCommand]
2524
private async Task RefreshExternalPluginsAsync()
2625
{
27-
if (await PluginsManifest.UpdateManifestAsync())
26+
if (await App.API.UpdatePluginManifestAsync())
2827
{
2928
OnPropertyChanged(nameof(ExternalPlugins));
3029
}

Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Windows.Controls;
44
using System.Threading.Tasks;
55
using System.Threading;
6-
using Flow.Launcher.Core.ExternalPlugins;
76
using Flow.Launcher.Plugin.PluginsManager.ViewModels;
87
using Flow.Launcher.Plugin.PluginsManager.Views;
98

@@ -34,7 +33,7 @@ public async Task InitAsync(PluginInitContext context)
3433
contextMenu = new ContextMenu(Context);
3534
pluginManager = new PluginsManager(Context, Settings);
3635

37-
await PluginsManifest.UpdateManifestAsync();
36+
await Context.API.UpdatePluginManifestAsync();
3837
}
3938

4039
public List<Result> LoadContextMenus(Result selectedResult)

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Flow.Launcher.Core.ExternalPlugins;
2-
using Flow.Launcher.Core.Plugin;
1+
using Flow.Launcher.Core.Plugin;
32
using Flow.Launcher.Plugin.SharedCommands;
43
using System;
54
using System.Collections.Generic;
@@ -236,7 +235,7 @@ await Context.API.ShowProgressBoxAsync(prgBoxTitle,
236235
internal async ValueTask<List<Result>> RequestUpdateAsync(string search, CancellationToken token,
237236
bool usePrimaryUrlOnly = false)
238237
{
239-
await PluginsManifest.UpdateManifestAsync(usePrimaryUrlOnly, token);
238+
await Context.API.UpdatePluginManifestAsync(usePrimaryUrlOnly, token);
240239

241240
var pluginFromLocalPath = null as UserPlugin;
242241
var updateFromLocalPath = false;
@@ -249,7 +248,7 @@ internal async ValueTask<List<Result>> RequestUpdateAsync(string search, Cancell
249248
}
250249

251250
var updateSource = !updateFromLocalPath
252-
? PluginsManifest.UserPlugins
251+
? Context.API.GetUserPlugins()
253252
: new List<UserPlugin> { pluginFromLocalPath };
254253

255254
var resultsForUpdate = (
@@ -601,7 +600,7 @@ private bool InstallSourceKnown(string url)
601600
internal async ValueTask<List<Result>> RequestInstallOrUpdateAsync(string search, CancellationToken token,
602601
bool usePrimaryUrlOnly = false)
603602
{
604-
await PluginsManifest.UpdateManifestAsync(usePrimaryUrlOnly, token);
603+
await Context.API.UpdatePluginManifestAsync(usePrimaryUrlOnly, token);
605604

606605
if (Uri.IsWellFormedUriString(search, UriKind.Absolute)
607606
&& search.Split('.').Last() == ZipSuffix)
@@ -611,8 +610,7 @@ internal async ValueTask<List<Result>> RequestInstallOrUpdateAsync(string search
611610
return InstallFromLocalPath(search);
612611

613612
var results =
614-
PluginsManifest
615-
.UserPlugins
613+
Context.API.GetUserPlugins()
616614
.Where(x => !PluginExists(x.ID) && !PluginManager.PluginModified(x.ID))
617615
.Select(x =>
618616
new Result

0 commit comments

Comments
 (0)