mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-13 06:07:30 -04:00
When Libation cannot install an upgrade itself - a portable or AppImage install, a Linux build with no package-manager symlink, macOS outside /Applications - the prompt is a notice with a download link, and Chardonnay relabels its button from "Yes" to "OK" to say so. The button still closed with DialogResult.OK, which MainWindow and the About window both read as "yes, install it", so acknowledging the notice downloaded the release and ran the auto-upgrader anyway. That could only fail, and it failed loudly: an "Upgrade Failed" error box in answer to dismissing a notice. The button now closes with Cancel when there was no upgrade on offer, so the answer matches the question. Classic already did the equivalent, hiding its Yes button and relabelling No. UpgraderBase gets the matching guard. It already refused to install under Windows Application Control on the grounds that a UI ignoring CapUpgrade must not be able to start an upgrade that leaves Libation unable to start; that reasoning covers every capped upgrade, not just the Windows one, so the stop is now keyed on CapUpgrade itself via MayInstallUpgrade. Co-authored-by: rmcrackan <rmcrackan@gmail.com>
59 lines
3.2 KiB
C#
59 lines
3.2 KiB
C#
using AppScaffolding;
|
|
using Avalonia.Controls;
|
|
using Dinah.Core;
|
|
using LibationFileManager;
|
|
using LibationUiBase.Forms;
|
|
|
|
namespace LibationAvalonia.Dialogs;
|
|
|
|
public partial class UpgradeNotificationDialog : DialogWindow
|
|
{
|
|
private const string UpdateMessage = "There is a new version available. Would you like to update?\r\n\r\nAfter you close Libation, the upgrade will start automatically.";
|
|
public string? TopMessage { get; }
|
|
public string? DownloadLinkText { get; }
|
|
public string? ReleaseNotes { get; }
|
|
public string? OkText { get; }
|
|
private string? PackageUrl { get; }
|
|
private bool CanUpgrade { get; } = true;
|
|
public UpgradeNotificationDialog()
|
|
{
|
|
if (Design.IsDesignMode)
|
|
{
|
|
TopMessage = UpdateMessage;
|
|
Title = "Libation version 8.7.0 is now available.";
|
|
DownloadLinkText = "\r\nLibation.12.7.0-macOS-chardonnay-arm64.tgz ";
|
|
ReleaseNotes = "New features:\r\n\r\n* 'Remove' now removes forever. Removed books won't be re-added on next scan\r\n* #406 : Right Click Menu for Stop-Light Icon\r\n* #398 : Grid, right-click, copy\r\n* Add option for user to choose custom temp folder\r\n* Build Docker image\r\n\r\nEnhancements\r\n\r\n* Illegal Char Replace dialog in Chardonnay\r\n* Filename character replacement allows replacing any char, not just illegal\r\n* #352 : Better error messages for license denial\r\n* Improve 'cancel download'\r\n\r\nThanks to @Mbucari (u/MSWMan), @pixil98 (u/pixil)\r\n\r\nLibation is a free, open source audible library manager for Windows. Decrypt, backup, organize, and search your audible library\r\n\r\nI intend to keep Libation free and open source, but if you want to leave a tip, who am I to argue?";
|
|
OkText = "Yes";
|
|
DataContext = this;
|
|
}
|
|
|
|
InitializeComponent();
|
|
ControlToFocusOnShow = btnYes;
|
|
}
|
|
|
|
public UpgradeNotificationDialog(UpgradeProperties upgradeProperties, bool canUpgrade, string? upgradeUnavailableReason = null) : this()
|
|
{
|
|
Title = $"Libation version {upgradeProperties.LatestRelease.ToVersionString()} is now available.";
|
|
CanUpgrade = canUpgrade;
|
|
PackageUrl = upgradeProperties.ZipUrl;
|
|
DownloadLinkText = upgradeProperties.ZipName;
|
|
ReleaseNotes = upgradeProperties.Notes;
|
|
TopMessage = canUpgrade ? UpdateMessage : upgradeUnavailableReason ?? "";
|
|
OkText = canUpgrade ? "Yes" : "OK";
|
|
DataContext = this;
|
|
}
|
|
|
|
// When Libation cannot install the upgrade itself, this button reads "OK" and the dialog is a
|
|
// notice with a download link. Reporting OK there would be read as "yes, install it", starting a
|
|
// download and an install that was never on offer, so acknowledging a notice closes and no more.
|
|
public void OK_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
|
=> Close(CanUpgrade ? DialogResult.OK : DialogResult.Cancel);
|
|
public void DontRemind_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => Close(DialogResult.Ignore);
|
|
public void Download_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
|
|
=> Go.To.Url(PackageUrl);
|
|
public void Website_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
|
|
=> Go.To.Url(LibationScaffolding.WebsiteUrl);
|
|
public void Github_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
|
|
=> Go.To.Url(LibationScaffolding.RepositoryUrl);
|
|
}
|