[gnome-software: 2/25] gs-odrs-provider: Inline a helper function
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 2/25] gs-odrs-provider: Inline a helper function
- Date: Tue, 1 Mar 2022 12:28:12 +0000 (UTC)
commit 7b545a5de02687d2cc895ab2591f26de98084a0a
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Feb 23 13:17:35 2022 +0000
gs-odrs-provider: Inline a helper function
It’s only called in one place, and the following commit will make this
code asynchronous. If this were to stay as a helper function, it would
need its own `GTask`, which would complicate things for no benefit.
This introduces no functional changes.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1658
lib/gs-odrs-provider.c | 69 +++++++++++++++++++++-----------------------------
1 file changed, 29 insertions(+), 40 deletions(-)
---
diff --git a/lib/gs-odrs-provider.c b/lib/gs-odrs-provider.c
index 00f3f9737..147fd62d4 100644
--- a/lib/gs-odrs-provider.c
+++ b/lib/gs-odrs-provider.c
@@ -819,43 +819,6 @@ gs_odrs_provider_fetch_for_app (GsOdrsProvider *self,
return g_steal_pointer (&reviews);
}
-static gboolean
-gs_odrs_provider_refine_reviews (GsOdrsProvider *self,
- GsApp *app,
- GCancellable *cancellable,
- GError **error)
-{
- AsReview *review;
- g_autoptr(GPtrArray) reviews = NULL;
-
- /* get from server */
- reviews = gs_odrs_provider_fetch_for_app (self, app, cancellable, error);
- if (reviews == NULL)
- return FALSE;
- for (guint i = 0; i < reviews->len; i++) {
- review = g_ptr_array_index (reviews, i);
-
- /* save this on the application object so we can use it for
- * submitting a new review */
- if (i == 0) {
- gs_app_set_metadata (app, "ODRS::user_skey",
- as_review_get_metadata_item (review, "user_skey"));
- }
-
- /* ignore invalid reviews */
- if (as_review_get_rating (review) == 0)
- continue;
-
- /* the user_hash matches, so mark this as our own review */
- if (g_strcmp0 (as_review_get_reviewer_id (review),
- self->user_hash) == 0) {
- as_review_set_flags (review, AS_REVIEW_FLAG_SELF);
- }
- gs_app_add_review (app, review);
- }
- return TRUE;
-}
-
static gboolean
refine_app (GsOdrsProvider *self,
GsApp *app,
@@ -871,11 +834,37 @@ refine_app (GsOdrsProvider *self,
/* add reviews if possible */
if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS) {
- if (gs_app_get_reviews(app)->len > 0)
+ AsReview *review;
+ g_autoptr(GPtrArray) reviews = NULL;
+
+ if (gs_app_get_reviews (app)->len > 0)
return TRUE;
- if (!gs_odrs_provider_refine_reviews (self, app,
- cancellable, error))
+
+ /* get from server */
+ reviews = gs_odrs_provider_fetch_for_app (self, app, cancellable, error);
+ if (reviews == NULL)
return FALSE;
+ for (guint i = 0; i < reviews->len; i++) {
+ review = g_ptr_array_index (reviews, i);
+
+ /* save this on the application object so we can use it for
+ * submitting a new review */
+ if (i == 0) {
+ gs_app_set_metadata (app, "ODRS::user_skey",
+ as_review_get_metadata_item (review, "user_skey"));
+ }
+
+ /* ignore invalid reviews */
+ if (as_review_get_rating (review) == 0)
+ continue;
+
+ /* the user_hash matches, so mark this as our own review */
+ if (g_strcmp0 (as_review_get_reviewer_id (review),
+ self->user_hash) == 0) {
+ as_review_set_flags (review, AS_REVIEW_FLAG_SELF);
+ }
+ gs_app_add_review (app, review);
+ }
}
/* add ratings if possible */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]