From 732dceb4fa9b255af3e40c8bf5856f3d625eafa8 Mon Sep 17 00:00:00 2001 From: Richard Tibbles <richard@learningequality.org> Date: Tue, 9 Nov 2021 16:17:24 -0800 Subject: [PATCH] Properly fetch more progress for tree data. Only fetch it when logged in. --- .../assets/src/composables/useContentNodeProgress.js | 2 +- .../learn/assets/src/modules/topicsTree/handlers.js | 2 +- .../plugins/learn/assets/src/modules/topicsTree/index.js | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kolibri/plugins/learn/assets/src/composables/useContentNodeProgress.js b/kolibri/plugins/learn/assets/src/composables/useContentNodeProgress.js index 01da1c5674a..a3d9b95da21 100644 --- a/kolibri/plugins/learn/assets/src/composables/useContentNodeProgress.js +++ b/kolibri/plugins/learn/assets/src/composables/useContentNodeProgress.js @@ -43,7 +43,7 @@ export default function useContentNodeProgress() { * @returns {Promise} * @public */ - function fetchContentNodeTreeProgress(id, params) { + function fetchContentNodeTreeProgress({ id, params }) { return ContentNodeProgressResource.fetchTree({ params, id, diff --git a/kolibri/plugins/learn/assets/src/modules/topicsTree/handlers.js b/kolibri/plugins/learn/assets/src/modules/topicsTree/handlers.js index 5aed8fb0d77..b4a75271c8d 100644 --- a/kolibri/plugins/learn/assets/src/modules/topicsTree/handlers.js +++ b/kolibri/plugins/learn/assets/src/modules/topicsTree/handlers.js @@ -43,7 +43,7 @@ export function showTopicsTopic(store, { id, pageName }) { store.getters.isAdmin || store.getters.isCoach || store.getters.isSuperuser, }; if (store.getters.isUserLoggedIn) { - fetchContentNodeTreeProgress(id, params); + fetchContentNodeTreeProgress({ id, params }); } return ContentNodeResource.fetchTree({ id, diff --git a/kolibri/plugins/learn/assets/src/modules/topicsTree/index.js b/kolibri/plugins/learn/assets/src/modules/topicsTree/index.js index 8a1ad97fcae..d39ed03949c 100644 --- a/kolibri/plugins/learn/assets/src/modules/topicsTree/index.js +++ b/kolibri/plugins/learn/assets/src/modules/topicsTree/index.js @@ -43,7 +43,9 @@ export default { loadMoreTopics(store) { const more = store.state.topic.children.more; if (more) { - fetchContentNodeTreeProgress(more); + if (store.rootGetters.isUserLoggedIn) { + fetchContentNodeTreeProgress(more); + } return ContentNodeResource.fetchTree(more) .then(data => { store.commit('ADD_MORE_CONTENTS', data); @@ -58,7 +60,9 @@ export default { const parent = parentIndex > -1 ? store.state.contents[parentIndex] : null; const more = parent && parent.children && parent.children.more; if (more) { - fetchContentNodeTreeProgress(more); + if (store.rootGetters.isUserLoggedIn) { + fetchContentNodeTreeProgress(more); + } return ContentNodeResource.fetchTree(more) .then(data => { data.index = parentIndex;