add manifest handling of plugin's MinimumAppVersion property

This commit is contained in:
Jeremy 2025-09-02 22:11:08 +10:00
parent ca01d15dde
commit 563ae0eeaf
2 changed files with 32 additions and 5 deletions

View file

@ -4,6 +4,7 @@ using System.Threading;
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 @@ namespace Flow.Launcher.Core.ExternalPlugins
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;
return true;
lastFetchedAt = DateTime.Now;
var updatedPluginResult = new List<UserPlugin>();
var appVersion = SemanticVersioning.Version.Parse(Constant.Version);
for (int i = 0; i < results.Count; i++)
{
if (IsMinimumAppVersionSatisfied(results[i], appVersion))
updatedPluginResult.Add(results[i]);
}
UserPlugins = updatedPluginResult;
return true;
}
}
catch (Exception e)
@ -59,5 +70,16 @@ namespace Flow.Launcher.Core.ExternalPlugins
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;
}
}
}

View file

@ -76,5 +76,10 @@ namespace Flow.Launcher.Plugin
/// 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;
}
}