diff --git a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs index e58b299f641..f8b56548200 100644 --- a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs +++ b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs @@ -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 { @@ -39,13 +40,23 @@ public static async Task 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(); + 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) @@ -59,5 +70,16 @@ public static async Task 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; + } } } diff --git a/Flow.Launcher.Plugin/UserPlugin.cs b/Flow.Launcher.Plugin/UserPlugin.cs index 74a16b83d80..4257a8b2e70 100644 --- a/Flow.Launcher.Plugin/UserPlugin.cs +++ b/Flow.Launcher.Plugin/UserPlugin.cs @@ -76,5 +76,10 @@ public record UserPlugin /// Indicates whether the plugin is installed from a local path /// public bool IsFromLocalInstallPath => !string.IsNullOrEmpty(LocalInstallPath); + + /// + /// The minimum Flow Launcher version required for this plugin. Default is "". + /// + public string MinimumAppVersion { get; set; } = string.Empty; } }