feat: display 3pp changelogs

This commit is contained in:
Aireil 2023-03-18 16:14:28 +01:00
parent bea7ab56b1
commit d7c510647e
No known key found for this signature in database
GPG key ID: EA9CA38B48706D3D
2 changed files with 33 additions and 6 deletions

View file

@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using Dalamud.Plugin.Internal;
using Dalamud.Utility;
using Serilog;
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
@ -49,17 +50,29 @@ internal class DalamudChangelogManager
foreach (var plugin in this.manager.InstalledPlugins)
{
if (plugin.Manifest.IsThirdParty || !plugin.Manifest.IsDip17Plugin)
continue;
if (!plugin.Manifest.IsThirdParty)
{
if (!plugin.Manifest.IsDip17Plugin)
continue;
var pluginChangelogs = await client.GetFromJsonAsync<PluginHistory>(string.Format(
var pluginChangelogs = await client.GetFromJsonAsync<PluginHistory>(string.Format(
PluginChangelogUrl,
plugin.Manifest.InternalName,
plugin.Manifest.Dip17Channel));
changelogs = changelogs.Concat(pluginChangelogs.Versions
.Where(x => x.Dip17Track == plugin.Manifest.Dip17Channel)
.Select(x => new PluginChangelogEntry(plugin, x)));
changelogs = changelogs.Concat(pluginChangelogs.Versions
.Where(x => x.Dip17Track == plugin.Manifest.Dip17Channel)
.Select(x => new PluginChangelogEntry(plugin, x)));
}
else
{
if (plugin.Manifest.Changelog.IsNullOrWhitespace())
continue;
changelogs = changelogs.Append(new PluginChangelogEntry(plugin));
}
}
this.Changelogs = changelogs.OrderByDescending(x => x.Date).ToList();

View file

@ -25,6 +25,20 @@ internal class PluginChangelogEntry : IChangelogEntry
this.Date = history.PublishedAt;
}
/// <summary>
/// Initializes a new instance of the <see cref="PluginChangelogEntry"/> class.
/// </summary>
/// <param name="plugin">The plugin manifest.</param>
public PluginChangelogEntry(LocalPlugin plugin)
{
this.Plugin = plugin;
this.Version = plugin.Manifest.EffectiveVersion.ToString();
this.Text = plugin.Manifest.Changelog ?? Loc.Localize("ChangelogNoText", "No changelog for this version.");
this.Author = plugin.Manifest.Author;
this.Date = DateTimeOffset.FromUnixTimeSeconds(this.Plugin.Manifest.LastUpdate).DateTime;
}
/// <summary>
/// Gets the respective plugin.
/// </summary>