mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[CmdPal] Fix details pane not hiding when item initialization fails (#44757)
Fixes #44487 ## Summary Fixed issue where the details pane would display stale information when navigating from an item with details to an item without details or where details failed to load. ## Changes 1. **ListViewModel.cs**: Added HideDetailsMessage when SafeSlowInit() fails to ensure previous details are cleared 2. **InstallPackageListItem.cs**: Added exception handling for WinRT marshaling errors when accessing metadata.Documentations and metadata.Tags collections The fix ensures graceful degradation - if certain metadata collections fail to load due to WinRT issues, the details pane still displays available information rather than failing completely.
This commit is contained in:
@@ -132,12 +132,20 @@ public partial class InstallPackageListItem : ListItem
|
||||
// These can be l o n g
|
||||
{ Properties.Resources.winget_release_notes, (metadata.ReleaseNotes, string.Empty) },
|
||||
};
|
||||
var docs = metadata.Documentations;
|
||||
var count = docs.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
|
||||
try
|
||||
{
|
||||
var item = docs[i];
|
||||
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
|
||||
var docs = metadata.Documentations;
|
||||
var count = docs.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = docs[i];
|
||||
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning($"Failed to retrieve documentations from metadata: {ex.Message}");
|
||||
}
|
||||
|
||||
UriCreationOptions options = default;
|
||||
@@ -159,14 +167,21 @@ public partial class InstallPackageListItem : ListItem
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata.Tags.Count > 0)
|
||||
try
|
||||
{
|
||||
DetailsElement pair = new()
|
||||
if (metadata.Tags.Count > 0)
|
||||
{
|
||||
Key = "Tags",
|
||||
Data = new DetailsTags() { Tags = metadata.Tags.Select(t => new Tag(t)).ToArray() },
|
||||
};
|
||||
detailsElements.Add(pair);
|
||||
DetailsElement pair = new()
|
||||
{
|
||||
Key = "Tags",
|
||||
Data = new DetailsTags() { Tags = metadata.Tags.Select(t => new Tag(t)).ToArray() },
|
||||
};
|
||||
detailsElements.Add(pair);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning($"Failed to retrieve tags from metadata: {ex.Message}");
|
||||
}
|
||||
|
||||
return detailsElements;
|
||||
|
||||
Reference in New Issue
Block a user