fix: plugin config deletion context menu (#955)

This commit is contained in:
Aireil 2022-08-17 22:13:31 +02:00 committed by GitHub
parent 5ffe5690a4
commit 1e40a930a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View file

@ -2631,9 +2631,9 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
public static string PluginContext_HidePlugin => Loc.Localize("InstallerHidePlugin", "Hide from installer");
public static string PluginContext_DeletePluginConfig => Loc.Localize("InstallerDeletePluginConfig", "Reset plugin");
public static string PluginContext_DeletePluginConfig => Loc.Localize("InstallerDeletePluginConfig", "Reset plugin configuration");
public static string PluginContext_DeletePluginConfigReload => Loc.Localize("InstallerDeletePluginConfigReload", "Reset plugin settings & reload");
public static string PluginContext_DeletePluginConfigReload => Loc.Localize("InstallerDeletePluginConfigReload", "Reset plugin configuration and reload");
#endregion

View file

@ -1128,17 +1128,18 @@ internal partial class PluginManager : IDisposable, IServiceType
}
/// <summary>
/// Unload the plugin, delete its configuration, and reload it.
/// Delete the plugin configuration, unload/reload it if loaded.
/// </summary>
/// <param name="plugin">The plugin.</param>
/// <exception cref="Exception">Throws if the plugin is still loading/unloading.</exception>
/// <returns>The task.</returns>
public async Task DeleteConfigurationAsync(LocalPlugin plugin)
{
if (plugin.State == PluginState.Loading || plugin.State == PluginState.Unloaded)
if (plugin.State is PluginState.Loading or PluginState.Unloading)
throw new Exception("Cannot delete configuration for a loading/unloading plugin");
if (plugin.IsLoaded)
var isReloading = plugin.IsLoaded;
if (isReloading)
await plugin.UnloadAsync();
for (var waitUntil = Environment.TickCount64 + 1000; Environment.TickCount64 < waitUntil;)
@ -1154,8 +1155,11 @@ internal partial class PluginManager : IDisposable, IServiceType
}
}
// Let's indicate "installer" here since this is supposed to be a fresh install
await plugin.LoadAsync(PluginLoadReason.Installer);
if (isReloading)
{
// Let's indicate "installer" here since this is supposed to be a fresh install
await plugin.LoadAsync(PluginLoadReason.Installer);
}
}
/// <summary>