[Peek] Handle crash when opening app for Internet shortcuts (#26680)

* null check

* launch uri
This commit is contained in:
Seraphima Zykova
2023-06-26 17:19:44 +02:00
committed by GitHub
parent 397178deec
commit 67ce81ded8

View File

@@ -142,7 +142,14 @@ namespace Peek.UI.Views
PowerToysTelemetry.Log.WriteEvent(new OpenWithEvent() { App = DefaultAppName ?? string.Empty });
if (string.IsNullOrEmpty(DefaultAppName))
// StorageFile objects can't represent files that are ".lnk", ".url", or ".wsh" file types.
// https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefile?view=winrt-22621
if (storageFile == null)
{
options.DisplayApplicationPicker = true;
await Launcher.LaunchUriAsync(new Uri(Item.Path), options);
}
else if (string.IsNullOrEmpty(DefaultAppName))
{
// If there's no default app found, open the App picker
options.DisplayApplicationPicker = true;