[gnome-software/1105-gs-details-page-rating-histogram-hidden-when-being-offline] gs-plugins-odrs: Load ratings from the cache when refresh is skipped on start
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1105-gs-details-page-rating-histogram-hidden-when-being-offline] gs-plugins-odrs: Load ratings from the cache when refresh is skipped on start
- Date: Tue, 1 Dec 2020 16:42:33 +0000 (UTC)
commit 2663ab27c371829fe93b9fd47220f66f4985febd
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 1 17:39:30 2020 +0100
gs-plugins-odrs: Load ratings from the cache when refresh is skipped on start
Check whether any ratings are cached and load that at least, thus
the rating histogram at the details page can show information from the last run.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1105
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/554
plugins/odrs/gs-plugin-odrs.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/plugins/odrs/gs-plugin-odrs.c b/plugins/odrs/gs-plugin-odrs.c
index ca834990..ec2b5b1a 100644
--- a/plugins/odrs/gs-plugin-odrs.c
+++ b/plugins/odrs/gs-plugin-odrs.c
@@ -630,8 +630,27 @@ gs_plugin_odrs_refine_ratings (GsPlugin *plugin,
locker = g_mutex_locker_new (&priv->ratings_mutex);
- if (priv->ratings == NULL)
- return TRUE;
+ if (!priv->ratings) {
+ g_autofree gchar *cache_filename = NULL;
+
+ g_clear_pointer (&locker, g_mutex_locker_free);
+
+ /* Load from the local cache, if available, when in offline or
+ when refresh/download disabled on start */
+ cache_filename = gs_utils_get_cache_filename ("odrs",
+ "ratings.json",
+ GS_UTILS_CACHE_FLAG_WRITEABLE,
+ error);
+
+ if (!cache_filename ||
+ !gs_plugin_odrs_load_ratings (plugin, cache_filename, NULL))
+ return TRUE;
+
+ locker = g_mutex_locker_new (&priv->ratings_mutex);
+
+ if (!priv->ratings)
+ return TRUE;
+ }
for (guint i = 0; i < reviewable_ids->len; i++) {
const gchar *id = g_ptr_array_index (reviewable_ids, i);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]