perf: show whether plugin toggle is enable or disable (#2189)

This commit is contained in:
Vanillaaaa 2025-03-24 12:38:47 +08:00 committed by GitHub
parent 8939cac80f
commit 9815cf1d88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -216,7 +216,12 @@ internal class PluginManagementCommandHandler : IInternalDisposableService
this.chat.Print(onSuccess);
}
if (operation == PluginCommandOperation.Toggle)
{
operation = plugin.State == PluginState.Loaded ? PluginCommandOperation.Disable : PluginCommandOperation.Enable;
}
switch (operation)
{
case PluginCommandOperation.Enable:
@ -235,14 +240,6 @@ internal class PluginManagementCommandHandler : IInternalDisposableService
Loc.Localize("PluginCommandsDisableFailed", "Failed to disable plugin \"{0}\". Please check the console for errors.").Format(plugin.Name)))
.ConfigureAwait(false);
break;
case PluginCommandOperation.Toggle:
this.chat.Print(Loc.Localize("PluginCommandsToggling", "Toggling plugin \"{0}\"...").Format(plugin.Name));
Task.Run(() => plugin.State == PluginState.Loaded ? plugin.UnloadAsync() : plugin.LoadAsync(PluginLoadReason.Installer))
.ContinueWith(t => Continuation(t,
Loc.Localize("PluginCommandsToggleSuccess", "Plugin \"{0}\" toggled.").Format(plugin.Name),
Loc.Localize("PluginCommandsToggleFailed", "Failed to toggle plugin \"{0}\". Please check the console for errors.").Format(plugin.Name)))
.ConfigureAwait(false);
break;
default:
throw new ArgumentOutOfRangeException(nameof(operation), operation, null);
}