Skip to content

Commit

Permalink
Allow checking for UniGetUI updates without having automatic check en…
Browse files Browse the repository at this point in the history
…abled (fix #3091)
  • Loading branch information
marticliment committed Jan 18, 2025
1 parent 870e13c commit 0e0e3d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/UniGetUI/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static async Task UpdateCheckLoop(Window window, InfoBar banner)
/// <summary>
/// Performs the entire update process, and returns true/false whether the process finished successfully;
/// </summary>
public static async Task<bool> CheckAndInstallUpdates(Window window, InfoBar banner, bool Verbose, bool AutoLaunch = false)
public static async Task<bool> CheckAndInstallUpdates(Window window, InfoBar banner, bool Verbose, bool AutoLaunch = false, bool ManualCheck = false)
{
Window = window;
Banner = banner;
Expand Down Expand Up @@ -90,7 +90,7 @@ public static async Task<bool> CheckAndInstallUpdates(Window window, InfoBar ban
&& await CheckInstallerHash(InstallerPath, InstallerHash))
{
Logger.Info($"A cached valid installer was found, launching update process...");
return await PrepairToLaunchInstaller(InstallerPath, LatestVersion, AutoLaunch);
return await PrepairToLaunchInstaller(InstallerPath, LatestVersion, AutoLaunch, ManualCheck);
}
else
{
Expand All @@ -109,7 +109,7 @@ public static async Task<bool> CheckAndInstallUpdates(Window window, InfoBar ban
if (await CheckInstallerHash(InstallerPath, InstallerHash))
{
Logger.Info("The downloaded installer is valid, launching update process...");
return await PrepairToLaunchInstaller(InstallerPath, LatestVersion, AutoLaunch);
return await PrepairToLaunchInstaller(InstallerPath, LatestVersion, AutoLaunch, ManualCheck);
}
else
{
Expand Down Expand Up @@ -218,7 +218,7 @@ private static async Task DownloadInstaller(string downloadUrl, string installer
/// <summary>
/// Waits for the window to be closed if it is open and launches the updater
/// </summary>
private static async Task<bool> PrepairToLaunchInstaller(string installerLocation, string NewVersion, bool AutoLaunch)
private static async Task<bool> PrepairToLaunchInstaller(string installerLocation, string NewVersion, bool AutoLaunch, bool ManualCheck)
{
Logger.Debug("Starting the process to launch the installer.");
UpdateReadyToBeInstalled = true;
Expand All @@ -227,7 +227,7 @@ private static async Task<bool> PrepairToLaunchInstaller(string installerLocatio
ReleaseLockForAutoupdate_UpdateBanner = false;

// Check if the user has disabled updates
if (Settings.Get("DisableAutoUpdateWingetUI"))
if (!ManualCheck && Settings.Get("DisableAutoUpdateWingetUI"))
{
Banner.IsOpen = false;
Logger.Warn("User disabled updates!");
Expand Down Expand Up @@ -279,7 +279,7 @@ private static async Task<bool> PrepairToLaunchInstaller(string installerLocatio
Logger.Debug("Autoupdater lock released, launching installer...");
}

if (Settings.Get("DisableAutoUpdateWingetUI"))
if (!ManualCheck && Settings.Get("DisableAutoUpdateWingetUI"))
{
Logger.Warn("User has disabled updates");
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
<widgets:TranslatedTextBlock Text="Is your language missing or incomplete?" Opacity=".8" VerticalAlignment="Center"/>
<HyperlinkButton
Padding="0"
NavigateUri="https://github.com/marticliment/WingetUI/wiki#translating-wingetui"
>
NavigateUri="https://github.com/marticliment/WingetUI/wiki#translating-wingetui">
<widgets:TranslatedTextBlock Text="Become a translator"/>
</HyperlinkButton>
</StackPanel>
Expand All @@ -79,6 +78,7 @@
CheckboxText="Update WingetUI automatically"
ButtonText="Check for updates"
SettingName="DisableAutoUpdateWingetUI"
ButtonAlwaysOn="true"
Click="ForceUpdateUniGetUI_OnClick"
/>
<widgets:CheckboxCard
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,8 @@ private void DisableSelectingUpdatesByDefault_OnClick(object sender, EventArgs e

private void ForceUpdateUniGetUI_OnClick(object? sender, RoutedEventArgs e)
{
_ = AutoUpdater.CheckAndInstallUpdates(MainApp.Instance.MainWindow, MainApp.Instance.MainWindow.UpdatesBanner,
true);
var mainWindow = MainApp.Instance.MainWindow;
_ = AutoUpdater.CheckAndInstallUpdates(mainWindow, mainWindow.UpdatesBanner, true, false, true);
}

private void CheckboxButtonCard_OnClick(object? sender, RoutedEventArgs e)
Expand Down

0 comments on commit 0e0e3d2

Please sign in to comment.