feat: add IsAutoUpdateComplete to DPI

This commit is contained in:
goat 2023-05-21 19:18:11 +02:00
parent 839519b2bb
commit ca8a05b672
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 18 additions and 4 deletions

View file

@ -110,7 +110,7 @@ public class ChatHandlers : IServiceType
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
private bool hasSeenLoadingMsg;
private bool hasAutoUpdatedPlugins;
private bool startedAutoUpdatingPlugins;
[ServiceManager.ServiceConstructor]
private ChatHandlers(ChatGui chatGui)
@ -129,6 +129,11 @@ public class ChatHandlers : IServiceType
/// </summary>
public string? LastLink { get; private set; }
/// <summary>
/// Gets a value indicating whether or not auto-updates have already completed this session.
/// </summary>
public bool IsAutoUpdateComplete { get; private set; }
/// <summary>
/// Convert a TextPayload to SeString and wrap in italics payloads.
/// </summary>
@ -185,7 +190,7 @@ public class ChatHandlers : IServiceType
if (clientState.LocalPlayer != null && clientState.TerritoryType == 0 && !this.hasSeenLoadingMsg)
this.PrintWelcomeMessage();
if (!this.hasAutoUpdatedPlugins)
if (!this.startedAutoUpdatingPlugins)
this.AutoUpdatePlugins();
#if !DEBUG && false
@ -289,13 +294,16 @@ public class ChatHandlers : IServiceType
if (!pluginManager.ReposReady || pluginManager.InstalledPlugins.Count == 0 || pluginManager.AvailablePlugins.Count == 0)
{
// Plugins aren't ready yet.
// TODO: We should retry. This sucks, because it means we won't ever get here again until another notice.
return;
}
this.hasAutoUpdatedPlugins = true;
this.startedAutoUpdatingPlugins = true;
Task.Run(() => pluginManager.UpdatePluginsAsync(true, !this.configuration.AutoUpdatePlugins, true)).ContinueWith(task =>
{
this.IsAutoUpdateComplete = true;
if (task.IsFaulted)
{
Log.Error(task.Exception, Loc.Localize("DalamudPluginUpdateCheckFail", "Could not check for plugin updates."));

View file

@ -10,6 +10,7 @@ using System.Reflection;
using Dalamud.Configuration;
using Dalamud.Configuration.Internal;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.Gui;
using Dalamud.Game.Text;
using Dalamud.Game.Text.Sanitizer;
@ -110,6 +111,11 @@ public sealed class DalamudPluginInterface : IDisposable
/// </summary>
public PluginLoadReason Reason { get; }
/// <summary>
/// Gets a value indicating whether or not auto-updates have already completed this session.
/// </summary>
public bool IsAutoUpdateComplete => Service<ChatHandlers>.Get().IsAutoUpdateComplete;
/// <summary>
/// Gets the repository from which this plugin was installed.
///
@ -123,7 +129,7 @@ public sealed class DalamudPluginInterface : IDisposable
/// Gets the current internal plugin name.
/// </summary>
public string InternalName => this.pluginName;
/// <summary>
/// Gets a value indicating whether this is a dev plugin.
/// </summary>