/// <summary> /// Called when Package Manager has completed a remove request. /// </summary> static void CompleteUninstallEvent() { var targetPack = s_CurrentEvent.targetPack; var removeRequest = s_CurrentEvent.request as RemoveRequest; if (removeRequest == null) { return; } if (removeRequest.Status == StatusCode.Failure) { targetPack.InstallStatus &= ~(InstallationStatus.UninstallRequested | InstallationStatus.Locked); OnUninstallContent?.Invoke(false, removeRequest.Error.message); OnContentChanged?.Invoke(); return; } targetPack.InstallStatus = InstallationStatus.Unknown; OnUninstallContent?.Invoke(true, $"Successfully uninstalled {s_CurrentEvent.targetPack.PackageName}"); OnContentChanged?.Invoke(); // We do an update here to ensure icon state is maintained - enough can change between dependencies and cross-references that just changing the target pack can be misleading if (QueuedEvents.Count == 0) { UpdateContentStatus(); } }
/// <summary> /// Attempts to remove the package that the currently active event contains. /// </summary> static void StartUninstallEvent() { // If the package is not installed, do nothing. if (!s_CurrentEvent.targetPack.InstallStatus.HasFlag(InstallationStatus.Installed)) { OnUninstallContent?.Invoke(true, $"{s_CurrentEvent.targetPack.PackageName} not installed"); s_CurrentEvent = null; return; } s_CurrentEvent.targetPack.InstallStatus |= InstallationStatus.Locked; s_CurrentEvent.request = Client.Remove(s_CurrentEvent.targetPack.PackageName); OnContentChanged?.Invoke(); }