diff --git a/kolibri/plugins/learn/assets/src/composables/useDownloadRequests.js b/kolibri/plugins/learn/assets/src/composables/useDownloadRequests.js index 6229cc9a5eb..256716ead47 100644 --- a/kolibri/plugins/learn/assets/src/composables/useDownloadRequests.js +++ b/kolibri/plugins/learn/assets/src/composables/useDownloadRequests.js @@ -25,6 +25,10 @@ const downloadRequestsTranslator = createTranslator('DownloadRequests', { message: 'Resource removed from my library', context: 'A message shown when a user has removed a resource from their library', }, + downloadComplete: { + message: 'Download complete', + context: 'A message shown to indicate that a download request has been completed', + }, }); // The reactive is defined in the outer scope so it can be used as a shared store @@ -147,6 +151,17 @@ export default function useDownloadRequests(store) { return Promise.resolve(); } + function showCompletedDownloadSnackbar() { + store.commit('CORE_CREATE_SNACKBAR', { + text: downloadRequestsTranslator.$tr('downloadComplete'), + actionText: downloadRequestsTranslator.$tr('goToDownloadsPage'), + actionCallback: navigateToDownloads, + backdrop: false, + forceReuse: true, + autoDismiss: true, + }); + } + function removeDownloadRequest(contentNodeId) { const contentRequest = downloadRequestMap[contentNodeId]; if (!contentRequest) { @@ -179,5 +194,6 @@ export default function useDownloadRequests(store) { loading, removeDownloadRequest, downloadRequestsTranslator, + showCompletedDownloadSnackbar, }; } diff --git a/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue b/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue index 7b5d14df349..eea551c5df4 100644 --- a/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue +++ b/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue @@ -241,6 +241,7 @@ downloadRequestMap, downloadRequestsTranslator, pollUserDownloadRequests, + showCompletedDownloadSnackbar, loading: downloadRequestLoading, } = useDownloadRequests(); const deviceFormTranslator = crossComponentTranslator(AddDeviceForm); @@ -337,6 +338,7 @@ isAdmin, isSuperuser, currentUserId, + showCompletedDownloadSnackbar, }; }, props: { @@ -504,6 +506,11 @@ this.stopMainScroll(false); } }, + isDownloading(newVal) { + if (newVal === false && this.isDownloaded) { + this.showCompletedDownloadSnackbar(); + } + }, }, created() { this.initializeState();