Skip to content

Commit 4872867

Browse files
committed
More improvements to how icons and screenshots are loaded (fix #3620)
1 parent 4dd0864 commit 4872867

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/UniGetUI.Core.IconStore/IconDatabase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public async Task LoadIconAndScreenshotsDatabaseAsync()
5959
string IconsAndScreenshotsFile = Path.Join(CoreData.UniGetUICacheDirectory_Data, "Icon Database.json");
6060
try
6161
{
62-
Uri DownloadUrl = new("https://raw.githubusercontent.com/marticliment/UniGetUI/main/WebBasedData/screenshot-database-v2.json");
62+
Uri DownloadUrl = new("https://github.com/marticliment/UniGetUI/raw/refs/heads/main/WebBasedData/screenshot-database-v2.json");
6363
if (Settings.Get(Settings.K.IconDataBaseURL))
6464
{
6565
DownloadUrl = new Uri(Settings.GetValue(Settings.K.IconDataBaseURL));

src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/Helpers/BasePkgDetailsHelper.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public IReadOnlyList<string> GetVersions(IPackage package)
6060
{
6161
try
6262
{
63+
// Load native icon
6364
if (Manager.Capabilities.SupportsCustomPackageIcons)
6465
{
6566
var nativeIcon = GetIcon_UnSafe(package);
@@ -71,11 +72,11 @@ public IReadOnlyList<string> GetVersions(IPackage package)
7172

7273
// Try to get the icon especially for this package
7374
string? iconUrl = IconDatabase.Instance.GetIconUrlForId(Manager.Name + "." + package.Id);
74-
if (iconUrl is not null) return new CacheableIcon(new Uri(iconUrl), package.VersionString);
75+
if (iconUrl is not null) return new CacheableIcon(new Uri(iconUrl));
7576

7677
// Try to get other corresponding icons for the package
7778
iconUrl = IconDatabase.Instance.GetIconUrlForId(package.GetIconId());
78-
if (iconUrl is not null) return new CacheableIcon(new Uri(iconUrl), package.VersionString);
79+
if (iconUrl is not null) return new CacheableIcon(new Uri(iconUrl));
7980

8081
return null;
8182
} catch (Exception e)
@@ -92,6 +93,7 @@ public IReadOnlyList<Uri> GetScreenshots(IPackage package)
9293
{
9394
IReadOnlyList<Uri> URIs = [];
9495

96+
// Load native screenshots
9597
if (Manager.Capabilities.SupportsCustomPackageScreenshots)
9698
{
9799
URIs = GetScreenshots_UnSafe(package);
@@ -101,6 +103,19 @@ public IReadOnlyList<Uri> GetScreenshots(IPackage package)
101103
Logger.Debug($"Manager {Manager.Name} does not support native screenshots");
102104
}
103105

106+
// Try to get exact screenshots for this package
107+
if (!URIs.Any())
108+
{
109+
string[] UrlArray = IconDatabase.Instance.GetScreenshotsUrlForId(Manager.Name + "." + package.Id);
110+
List<Uri> UriList = [];
111+
foreach (string url in UrlArray)
112+
{
113+
if (url != "") UriList.Add(new Uri(url));
114+
}
115+
URIs = UriList;
116+
}
117+
118+
// Try to get matching screenshots for this package
104119
if (!URIs.Any())
105120
{
106121
string[] UrlArray = IconDatabase.Instance.GetScreenshotsUrlForId(package.GetIconId());

0 commit comments

Comments
 (0)