Skip to content

Commit

Permalink
prevent "unknown url" dialog when clicking links on Details page, imp…
Browse files Browse the repository at this point in the history
…rovements to loading dialog
  • Loading branch information
marticliment committed Jan 16, 2025
1 parent 1a290a6 commit 8fae868
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/UniGetUI/AppOperationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ public static void Remove(AbstractOperation op)
_operationList.Remove(control);
}


/*
*
* OPERATION CREATION HELPERS
*
*/

public static async void AskLocationAndDownload(IPackage? package)
{
if (package is null) return;
Expand All @@ -51,10 +49,9 @@ public static async void AskLocationAndDownload(IPackage? package)
var details = package.Details;
await details.Load();

DialogHelper.HideLoadingDialog();

if (details.InstallerUrl is null)
{
DialogHelper.HideLoadingDialog();
var dialog = new ContentDialog();
dialog.Title = CoreTools.Translate("Download failed");
dialog.Content = CoreTools.Translate("No applicable installer was found for the package {0}", package.Name);
Expand Down Expand Up @@ -84,8 +81,9 @@ public static async void AskLocationAndDownload(IPackage? package)
savePicker.FileTypeChoices.Add("Default", [$".{extension}"]);



StorageFile file = await savePicker.PickSaveFileAsync();

DialogHelper.HideLoadingDialog();
if (file is not null)
{
Add(new DownloadOperation(package, file.Path));
Expand All @@ -99,7 +97,6 @@ public static async void AskLocationAndDownload(IPackage? package)
}



/*
* PACKAGE INSTALLATION
*/
Expand Down
4 changes: 3 additions & 1 deletion src/UniGetUI/Pages/DialogPages/DialogHelper_Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public static void ShowLoadingDialog(string text)
ShowLoadingDialog(text, "");
}

public static void ShowLoadingDialog(string title, string description)
public static async void ShowLoadingDialog(string title, string description)
{
while (Window.LoadingDialogCount == 0 && Window.DialogQueue.Count != 0) await Task.Delay(100);

if (Window.LoadingDialogCount == 0 && Window.DialogQueue.Count == 0)
{
Window.LoadingSthDalog.Title = title;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/DialogPages/PackageDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<Run x:Name="InstallerHash_Label" FontWeight="Bold">Installer hash:</Run>
<Run x:Name="InstallerHash_Content">Helo</Run>
<LineBreak/>
<Hyperlink x:Name="DownloadInstaller_Button" FontWeight="Bold" TextDecorations="None" NavigateUri="about:blank">Download installer</Hyperlink>
<Hyperlink x:Name="DownloadInstaller_Button" FontWeight="Bold" TextDecorations="None">Download installer</Hyperlink>
<Run x:Name="InstallerSize_Content"></Run>
<LineBreak/>
<LineBreak/>
Expand Down
6 changes: 3 additions & 3 deletions src/UniGetUI/Pages/DialogPages/PackageDetailsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public void SetTextToItem(Run r, string? s)
else
{
r.Text = s;
r.ClearValue(Run.ForegroundProperty);
r.ClearValue(TextElement.ForegroundProperty);
}
}

Expand Down Expand Up @@ -415,7 +415,7 @@ public void SetTextToItem(Hyperlink h, string s)
{
h.Inlines.Clear();
h.Inlines.Add(new Run { Text = s });
h.NavigateUri = new Uri("about:blank");
h.NavigateUri = null;
}

public async void LoadIcon()
Expand Down Expand Up @@ -453,8 +453,8 @@ public void ShareButton_Click(object sender, RoutedEventArgs e)

public void DownloadInstallerButton_Click(object sender, RoutedEventArgs e)
{
MainApp.Operations.AskLocationAndDownload(Package);
Close?.Invoke(this, EventArgs.Empty);
MainApp.Operations.AskLocationAndDownload(Package);
}

public void CloseButton_Click(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 8fae868

Please sign in to comment.