feat: note if a plugin is no longer being serviced

This commit is contained in:
goaaats 2023-01-07 23:48:20 +01:00
parent 21b8adff4d
commit e3cbc4dc8c
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 51 additions and 2 deletions

View file

@ -220,8 +220,13 @@ internal class LocalPlugin : IDisposable
/// </summary>
public bool IsOrphaned => !this.IsDev &&
!this.Manifest.InstalledFromUrl.IsNullOrEmpty() && // TODO(api8): Remove this, all plugins will have a proper flag
Service<PluginManager>.Get().Repos.All(x => x.PluginMasterUrl != this.Manifest.InstalledFromUrl) &&
this.Manifest.InstalledFromUrl != LocalPluginManifest.FlagMainRepo;
this.GetSourceRepository() == null;
/// <summary>
/// Gets a value indicating whether or not this plugin is serviced(repo still exists, but plugin no longer does).
/// </summary>
public bool IsDecommissioned => !this.IsDev &&
this.GetSourceRepository()?.PluginMaster?.FirstOrDefault(x => x.InternalName == this.Manifest.InternalName) == null;
/// <summary>
/// Gets a value indicating whether this plugin has been banned.
@ -638,6 +643,25 @@ internal class LocalPlugin : IDisposable
}
}
/// <summary>
/// Get the repository this plugin was installed from.
/// </summary>
/// <returns>The plugin repository this plugin was installed from, or null if it is no longer there or if the plugin is a dev plugin.</returns>
public PluginRepository? GetSourceRepository()
{
if (this.IsDev)
return null;
var repos = Service<PluginManager>.Get().Repos;
return repos.FirstOrDefault(x =>
{
if (!x.IsThirdParty && !this.Manifest.IsThirdParty)
return true;
return x.PluginMasterUrl == this.Manifest.InstalledFromUrl;
});
}
private static void SetupLoaderConfig(LoaderConfig config)
{
config.IsUnloadable = true;