Skip to content

Commit c6b102a

Browse files
committed
Add a 'SimplePackage' structure
1 parent e32680a commit c6b102a

File tree

4 files changed

+61
-14
lines changed

4 files changed

+61
-14
lines changed

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,26 @@ public Package(
9898

9999
ignoredId = IgnoredUpdatesDatabase.GetIgnoredIdForPackage(this);
100100

101-
_iconId = Manager.Name switch
101+
_iconId = GetPackageIconId(id, Manager.Name, Source.Name);
102+
}
103+
104+
public static string GetPackageIconId(string PackageId, string ManagerName, string SourceName)
105+
{
106+
return ManagerName switch
102107
{
103-
"Winget" => Source.Name switch
108+
"Winget" => SourceName switch
104109
{
105-
"Steam" => id.ToLower().Split("\\")[^1].Replace("steam app ", "steam-").Trim(),
106-
"Local PC" => id.ToLower().Split("\\")[^1],
107-
"Microsoft Store" => id.IndexOf('_') < id.IndexOf('.') ? // If the first underscore is before the period, this ID has no publisher
108-
string.Join('_', id.ToLower().Split("\\")[1].Split("_")[0..^4]) : // no publisher: remove `MSIX\`, then the standard ending _version_arch__{random id}
109-
string.Join('_', string.Join('.', id.ToLower().Split(".")[1..]).Split("_")[0..^4]), // remove the publisher (before the first .), then the standard _version_arch__{random id}
110-
_ => string.Join('.', id.ToLower().Split(".")[1..]),
110+
"Steam" => PackageId.ToLower().Split("\\")[^1].Replace("steam app ", "steam-").Trim(),
111+
"Local PC" => PackageId.ToLower().Split("\\")[^1],
112+
"Microsoft Store" => PackageId.IndexOf('_') < PackageId.IndexOf('.') ? // If the first underscore is before the period, this ID has no publisher
113+
string.Join('_', PackageId.ToLower().Split("\\")[1].Split("_")[0..^4]) : // no publisher: remove `MSIX\`, then the standard ending _version_arch__{random id}
114+
string.Join('_', string.Join('.', PackageId.ToLower().Split(".")[1..]).Split("_")[0..^4]), // remove the publisher (before the first .), then the standard _version_arch__{random id}
115+
_ => string.Join('.', PackageId.ToLower().Split(".")[1..]),
111116
},
112-
"Scoop" => id.ToLower().Replace(".app", ""),
113-
"Chocolatey" => id.ToLower().Replace(".install", "").Replace(".portable", ""),
114-
"vcpkg" => id.ToLower().Split(":")[0].Split("[")[0],
115-
_ => id.ToLower()
117+
"Scoop" => PackageId.ToLower().Replace(".app", ""),
118+
"Chocolatey" => PackageId.ToLower().Replace(".install", "").Replace(".portable", ""),
119+
"vcpkg" => PackageId.ToLower().Split(":")[0].Split("[")[0],
120+
_ => PackageId.ToLower()
116121
};
117122
}
118123

src/UniGetUI/Pages/AdvancedOperationHistoryPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<DataTemplate x:DataType="local:AdvancedOperationHistoryEntry">
4343
<widgets:SettingsEntry
4444
Text="{x:Bind Title}"
45-
UnderText="{updated} on {March 10, 2025} at {11:27 AM}"
45+
UnderText="[updated] on [March 10, 2025] at [11:27 AM]"
4646
x:Name="InterfaceSettingsExpander"
4747
Icon="interactive"
4848
Margin="8">

src/UniGetUI/Pages/AdvancedOperationHistoryPage.xaml.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
using System.Collections.ObjectModel;
2+
using System.Data.Common;
23
using System.Diagnostics;
34
using ExternalLibraries.Clipboard;
45
using Microsoft.UI.Xaml;
56
using Microsoft.UI.Xaml.Controls;
7+
using UniGetUI.Core.SettingsEngine;
68
using UniGetUI.Core.Tools;
9+
using UniGetUI.Interface.Enums;
10+
using UniGetUI.PackageEngine.Interfaces;
11+
using UniGetUI.PackageEngine.PackageClasses;
712
using Windows.Storage;
813
using Windows.Storage.Pickers;
914
using Windows.UI;
@@ -19,9 +24,45 @@ public class AdvancedOperationHistoryEntry
1924
public required string Content { get; set; }
2025
}
2126

27+
public class SimplePackage
28+
{
29+
public string Description { get; }
30+
public string[] Tags { get; }
31+
public string Name { get; }
32+
public string Id { get; }
33+
public string VersionString { get; }
34+
public string NewVersionString { get; }
35+
public string IconId { get; }
36+
public string ManagerName { get; }
37+
public string ManagerDisplayName { get; }
38+
public string SourceName { get; }
39+
public Uri SourceUrl { get; }
40+
public IconType SourceIconId { get; }
41+
42+
public SimplePackage(IPackage Source)
43+
{
44+
// Load the details first
45+
Source.Details.Load();
46+
47+
// Now assign the values
48+
Description = Source.Details.Description ?? "No description";
49+
Tags = Source.Details.Tags;
50+
Name = Source.Name;
51+
Id = Source.Id;
52+
VersionString = Source.VersionString;
53+
NewVersionString = Source.NewVersionString;
54+
IconId = Package.GetPackageIconId(Source.Id, Source.Manager.Name, Source.Source.Name);
55+
ManagerName = Source.Manager.Name;
56+
ManagerDisplayName = Source.Manager.DisplayName;
57+
SourceName = Source.Source.Name;
58+
SourceUrl = Source.Source.Url;
59+
SourceIconId = Source.Source.IconId;
60+
}
61+
}
62+
2263
public partial class AdvancedOperationHistoryPage : IKeyboardShortcutListener, IEnterLeaveListener
2364
{
24-
private ObservableCollection<AdvancedOperationHistoryEntry> Items = new ();
65+
private readonly ObservableCollection<AdvancedOperationHistoryEntry> Items = [];
2566

2667
public AdvancedOperationHistoryPage()
2768
{

src/UniGetUI/Pages/SoftwarePages/InstalledPackagesPage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UniGetUI.Core.SettingsEngine;
66
using UniGetUI.Core.Tools;
77
using UniGetUI.Interface.Enums;
8+
using UniGetUI.Interface.Pages;
89
using UniGetUI.Interface.Telemetry;
910
using UniGetUI.Interface.Widgets;
1011
using UniGetUI.PackageEngine;

0 commit comments

Comments
 (0)