From f400dabc2777aa6795ce8423141ac44f689f68b7 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 15 Jun 2023 11:22:39 -0300 Subject: [PATCH 1/4] kolibriApi: Parameterize getContentByFilter() Instead of using the global value for unavailable content unconditionally, receive that as an option, and use the global value as fallback. --- kolibri_explore_plugin/assets/src/kolibriApi.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kolibri_explore_plugin/assets/src/kolibriApi.js b/kolibri_explore_plugin/assets/src/kolibriApi.js index 784bd1fdf..99b5005f4 100644 --- a/kolibri_explore_plugin/assets/src/kolibriApi.js +++ b/kolibri_explore_plugin/assets/src/kolibriApi.js @@ -65,6 +65,9 @@ class KolibriApi { } const kind = onlyContent ? 'content' : onlyTopics ? ContentNodeKinds.TOPIC : undefined; + const includeUnavailable = + 'includeUnavailable' in options ? options.includeUnavailable : !DEFAULT_HIDE_UNAVAILABLE; + return ContentNodeResource.fetchCollection({ getParams: { ids: options.ids, @@ -76,7 +79,7 @@ class KolibriApi { kind: kind, kind_in: kinds, descendant_of: options.descendantOf, - no_available_filtering: true, + ...(includeUnavailable && { no_available_filtering: true }), }, }).then(contentNodes => { const { more, results } = contentNodes; From 74efecc5a7a95926b2012d51993cde6542981c54 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 15 Jun 2023 11:30:42 -0300 Subject: [PATCH 2/4] Home: Add check to hide unavailable content Add a checkbox that is effectively equal to the one added to the Channel's search view. Changing the switch fetches the list of nodes again, passing the appropriate flag to KolibriApi. This is not optimal. One potential improvement is to always fetch unavailable content, and filter it within the view, but I've gone with this simpler approach given the time constraints. --- packages/template-ui/src/views/Home.vue | 41 ++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/packages/template-ui/src/views/Home.vue b/packages/template-ui/src/views/Home.vue index 5851e6667..f55b94a0d 100644 --- a/packages/template-ui/src/views/Home.vue +++ b/packages/template-ui/src/views/Home.vue @@ -20,7 +20,20 @@