Skip to content

Commit

Permalink
Package: remove redundant packagedetails (#2175)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Kornheisl <[email protected]>
  • Loading branch information
danirabbit and zeebok authored Jun 19, 2024
1 parent 6568ff4 commit f098b10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 78 deletions.
14 changes: 0 additions & 14 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -938,20 +938,6 @@ public class AppCenterCore.FlatpakBackend : Object {
return job.result.get_boolean ();
}

public async PackageDetails get_package_details (Package package) throws GLib.Error {
var details = new PackageDetails ();
details.name = package.component.get_name ();
details.description = package.component.get_description ();
details.summary = package.component.get_summary ();

var newest_version = package.get_newest_release ();
if (newest_version != null) {
details.version = newest_version.get_version ();
}

return details;
}

private void refresh_cache_internal (Job job) {
unowned var args = (RefreshCacheArgs)job.args;
unowned var cancellable = args.cancellable;
Expand Down
68 changes: 4 additions & 64 deletions src/Core/Package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ public errordomain PackageUninstallError {
APP_STATE_NOT_INSTALLED
}

public class AppCenterCore.PackageDetails : Object {
public string? name { get; set; }
public string? description { get; set; }
public string? summary { get; set; }
public string? version { get; set; }
}

public enum RuntimeStatus {
UP_TO_DATE,
END_OF_LIFE,
Expand Down Expand Up @@ -394,7 +387,6 @@ public class AppCenterCore.Package : Object {
internal set { _latest_version = convert_version (value); }
}

private PackageDetails? backend_details = null;
private AppInfo? app_info;
private bool app_info_retrieved = false;

Expand All @@ -419,7 +411,6 @@ public class AppCenterCore.Package : Object {
suggested_amount = null;
_author = null;
_author_title = null;
backend_details = null;

this.component = component;
}
Expand Down Expand Up @@ -585,14 +576,6 @@ public class AppCenterCore.Package : Object {
}

name = component.get_name ();
if (name == null) {
if (backend_details == null) {
populate_backend_details_sync ();
}

name = backend_details.name;
}

name = Utils.unescape_markup (name);

return name;
Expand All @@ -606,14 +589,6 @@ public class AppCenterCore.Package : Object {
if (description == null) {
description = component.get_description ();

if (description == null) {
if (backend_details == null) {
populate_backend_details_sync ();
}

description = backend_details.description;
}

if (description == null) {
return null;
}
Expand Down Expand Up @@ -642,13 +617,6 @@ public class AppCenterCore.Package : Object {
}

summary = component.get_summary ();
if (summary == null) {
if (backend_details == null) {
populate_backend_details_sync ();
}

summary = backend_details.summary;
}

return summary;
}
Expand Down Expand Up @@ -755,15 +723,12 @@ public class AppCenterCore.Package : Object {
return latest_version;
}

if (backend_details == null) {
populate_backend_details_sync ();
var newest_release = get_newest_release ();
if (newest_release != null) {
return newest_release.get_version ();
}

if (backend_details.version != null) {
latest_version = backend_details.version;
}

return latest_version;
return null;
}

public string? get_color_primary () {
Expand Down Expand Up @@ -887,29 +852,4 @@ public class AppCenterCore.Package : Object {

return size;
}

private void populate_backend_details_sync () {
if (is_runtime_updates || is_local) {
backend_details = new PackageDetails ();
return;
}

var loop = new MainLoop ();
PackageDetails? result = null;
AppCenterCore.FlatpakBackend.get_default ().get_package_details.begin (this, (obj, res) => {
try {
result = AppCenterCore.FlatpakBackend.get_default ().get_package_details.end (res);
} catch (Error e) {
warning (e.message);
} finally {
loop.quit ();
}
});

loop.run ();
backend_details = result;
if (backend_details == null) {
backend_details = new PackageDetails ();
}
}
}

0 comments on commit f098b10

Please sign in to comment.