diff --git a/kolibri/core/assets/src/api-resources/contentNode.js b/kolibri/core/assets/src/api-resources/contentNode.js index 57cd47e8d7c..db89e06f92d 100644 --- a/kolibri/core/assets/src/api-resources/contentNode.js +++ b/kolibri/core/assets/src/api-resources/contentNode.js @@ -104,8 +104,8 @@ export default new Resource({ fetchRecommendationsFor(id, getParams) { return this.fetchDetailCollection('recommendations_for', id, getParams); }, - fetchResume(getParams) { - return this.fetchDetailCollection('resume', Store.getters.currentUserId, getParams); + fetchResume(getParams, force) { + return this.fetchDetailCollection('resume', Store.getters.currentUserId, getParams, force); }, fetchPopular(getParams) { return this.fetchListCollection('popular', getParams); diff --git a/kolibri/plugins/learn/assets/src/composables/useLearnerResources.js b/kolibri/plugins/learn/assets/src/composables/useLearnerResources.js index ab2a3730646..e51596bf456 100644 --- a/kolibri/plugins/learn/assets/src/composables/useLearnerResources.js +++ b/kolibri/plugins/learn/assets/src/composables/useLearnerResources.js @@ -328,11 +328,12 @@ export default function useLearnerResources() { * Fetches resumable content nodes with their progress data * and saves data to this composable's store * + * @param {Boolean} force Cache won't be used when `true` * @returns {Promise} * @public */ - function fetchResumableContentNodes() { - return ContentNodeResource.fetchResume().then(contentNodes => { + function fetchResumableContentNodes({ force = false } = {}) { + return ContentNodeResource.fetchResume({}, force).then(contentNodes => { if (!contentNodes || !contentNodes.length) { return []; } @@ -340,6 +341,7 @@ export default function useLearnerResources() { const contentNodesIds = contentNodes.map(contentNode => contentNode.id); return ContentNodeProgressResource.fetchCollection({ getParams: { ids: contentNodesIds }, + force, }).then(progresses => { if (progresses) { set(_resumableContentNodesProgresses, progresses); diff --git a/kolibri/plugins/learn/assets/src/routes/index.js b/kolibri/plugins/learn/assets/src/routes/index.js index 0bcb6df6e2b..ed923649113 100644 --- a/kolibri/plugins/learn/assets/src/routes/index.js +++ b/kolibri/plugins/learn/assets/src/routes/index.js @@ -51,8 +51,11 @@ export default [ component: HomePage, handler() { let promises = [fetchChannels()]; + // force resumable content nodes request to make sure that the home + // page is up-to-date in regards to in-progress resources + // when navigating to other 'Learn' pages and then back to the home page if (get(isUserLoggedIn)) { - promises = [...promises, fetchClasses(), fetchResumableContentNodes()]; + promises = [...promises, fetchClasses(), fetchResumableContentNodes({ force: true })]; } return store.dispatch('loading').then(() => { return Promise.all(promises)