Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new developer id #2203

Merged
merged 9 commits into from
Aug 20, 2024
35 changes: 35 additions & 0 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,41 @@ public class AppCenterCore.FlatpakBackend : Object {
return packages;
}

public Gee.Collection<Package> get_packages_by_author_id (string author_id, int max) {
var packages = new Gee.ArrayList<AppCenterCore.Package> ();
var package_ids = new Gee.ArrayList<string> ();

foreach (var package in package_list.values) {
if (packages.size > max) {
break;
}

if (package.component.id in package_ids) {
continue;
}

if (package.component.get_developer ().get_id () == author_id) {
package_ids.add (package.component.id);

AppCenterCore.Package? user_package = null;
foreach (var origin_package in package.origin_packages) {
if (((FlatpakPackage) origin_package).installation == user_installation) {
user_package = origin_package;
break;
}
}

if (user_package != null) {
packages.add (user_package);
} else {
packages.add (package);
}
}
}

return packages;
}

public async uint64 get_download_size (Package package, Cancellable? cancellable, bool is_update = false) throws GLib.Error {
var bundle = package.component.get_bundle (AppStream.BundleKind.FLATPAK);
if (bundle == null) {
Expand Down
13 changes: 13 additions & 0 deletions src/Core/Package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,19 @@ public class AppCenterCore.Package : Object {
}
}

private string? _author_id = null;
public string? author_id {
get {
if (_author_id != null) {
return _author_id;
}

_author_id = component.get_developer ().get_id ();

return _author_id;
}
}

private string? _author_title = null;
public string author_title {
get {
Expand Down
7 changes: 6 additions & 1 deletion src/Views/AuthorView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ private class AppCenter.AuthorView : Gtk.Box {
return;
}

var author_packages = AppCenterCore.FlatpakBackend.get_default ().get_packages_by_author (package.author, AUTHOR_OTHER_APPS_MAX);
Gee.Collection<AppCenterCore.Package> author_packages;

author_packages = package.author_id == null
? AppCenterCore.FlatpakBackend.get_default ().get_packages_by_author (package.author, AUTHOR_OTHER_APPS_MAX)
: AppCenterCore.FlatpakBackend.get_default ().get_packages_by_author_id (package.author_id, AUTHOR_OTHER_APPS_MAX);

kerunaru marked this conversation as resolved.
Show resolved Hide resolved
if (author_packages.size <= 1) {
return;
}
Expand Down
Loading