Skip to content

Commit

Permalink
improving the reliability of installed apps list fetching (#612)
Browse files Browse the repository at this point in the history
improving the reliability of installed apps list fetching. Fixing this issue: #611

The URIs/logos of app have a reliable fallback value now so no error is thrown if they are invalid.

Also improved a small portion of the code to simplify an enum.
  • Loading branch information
HotCakeX authored Feb 21, 2025
1 parent 5c5ab4c commit 6eda7f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,7 @@ private void ScanLevelComboBox_SelectionChanged(object sender, SelectionChangedE
// Get the selected item from the ComboBox
string selectedText = (string)comboBox.SelectedItem;

if (!Enum.TryParse(selectedText, out scanLevel))
{
throw new InvalidOperationException($"{selectedText} is not a valid Scan Level");
}
scanLevel = Enum.Parse<ScanLevels>(selectedText);
}


Expand Down
12 changes: 11 additions & 1 deletion AppControl Manager/Pages/CreateDenyPolicy.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,22 @@ internal async Task<List<PackagedAppView>> GetAppsList()
// Loop over each package
foreach (Package item in allApps)
{
// Get the logo string (or an empty string if null)
string logoStr = item.Logo?.ToString() ?? string.Empty;

// Validate that the logo string is a valid absolute URI
if (!Uri.TryCreate(logoStr, UriKind.Absolute, out _))
{
// If invalid, assign a fallback logo
logoStr = "ms-appx:///Assets/StoreLogo.backup.png";
}

// Create a new instance of the class that displays each app in the ListView
apps.Add(new PackagedAppView(
displayName: item.DisplayName,
version: $"Version: {item.Id.Version.Major}.{item.Id.Version.Minor}.{item.Id.Version.Build}.{item.Id.Version.Revision}",
packageFamilyName: $"PFN: {item.Id.FamilyName}",
logo: item.Logo.ToString(),
logo: logoStr,
packageFamilyNameActual: item.Id.FamilyName
));
}
Expand Down
12 changes: 11 additions & 1 deletion AppControl Manager/Pages/CreateSupplementalPolicy.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,12 +1840,22 @@ internal async Task<List<PackagedAppView>> GetAppsList()
// Loop over each package
foreach (Package item in allApps)
{
// Get the logo string (or an empty string if null)
string logoStr = item.Logo?.ToString() ?? string.Empty;

// Validate that the logo string is a valid absolute URI
if (!Uri.TryCreate(logoStr, UriKind.Absolute, out _))
{
// If invalid, assign a fallback logo
logoStr = "ms-appx:///Assets/StoreLogo.backup.png";
}

// Create a new instance of the class that displays each app in the ListView
apps.Add(new PackagedAppView(
displayName: item.DisplayName,
version: $"Version: {item.Id.Version.Major}.{item.Id.Version.Minor}.{item.Id.Version.Build}.{item.Id.Version.Revision}",
packageFamilyName: $"PFN: {item.Id.FamilyName}",
logo: item.Logo.ToString(),
logo: logoStr,
packageFamilyNameActual: item.Id.FamilyName
));
}
Expand Down

0 comments on commit 6eda7f1

Please sign in to comment.