Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Plugin;
using Flow.Launcher.Infrastructure;

namespace Flow.Launcher.Core.ExternalPlugins
{
Expand Down Expand Up @@ -39,13 +40,23 @@ public static async Task<bool> UpdateManifestAsync(bool usePrimaryUrlOnly = fals
var results = await mainPluginStore.FetchAsync(token, usePrimaryUrlOnly).ConfigureAwait(false);

// If the results are empty, we shouldn't update the manifest because the results are invalid.
if (results.Count != 0)
{
UserPlugins = results;
lastFetchedAt = DateTime.Now;
if (results.Count == 0)
return false;

lastFetchedAt = DateTime.Now;

return true;
var updatedPluginResults = new List<UserPlugin>();
var appVersion = SemanticVersioning.Version.Parse(Constant.Version);

for (int i = 0; i < results.Count; i++)
{
if (IsMinimumAppVersionSatisfied(results[i], appVersion))
updatedPluginResults.Add(results[i]);
}

UserPlugins = updatedPluginResults;

return true;
}
}
catch (Exception e)
Expand All @@ -59,5 +70,16 @@ public static async Task<bool> UpdateManifestAsync(bool usePrimaryUrlOnly = fals

return false;
}

private static bool IsMinimumAppVersionSatisfied(UserPlugin plugin, SemanticVersioning.Version appVersion)
{
if (string.IsNullOrEmpty(plugin.MinimumAppVersion) || appVersion >= SemanticVersioning.Version.Parse(plugin.MinimumAppVersion))
return true;

API.LogDebug(ClassName, $"Plugin {plugin.Name} requires minimum Flow Launcher version {plugin.MinimumAppVersion}, "
+ $"but current version is {Constant.Version}. Plugin excluded from manifest.");

return false;
}
}
}
5 changes: 5 additions & 0 deletions Flow.Launcher.Plugin/UserPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,10 @@ public record UserPlugin
/// Indicates whether the plugin is installed from a local path
/// </summary>
public bool IsFromLocalInstallPath => !string.IsNullOrEmpty(LocalInstallPath);

/// <summary>
/// The minimum Flow Launcher version required for this plugin. Default is "".
/// </summary>
public string MinimumAppVersion { get; set; } = string.Empty;
}
}
Loading