Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notification for downloaded content completion #12295

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -179,5 +194,6 @@ export default function useDownloadRequests(store) {
loading,
removeDownloadRequest,
downloadRequestsTranslator,
showCompletedDownloadSnackbar,
};
}
7 changes: 7 additions & 0 deletions kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
downloadRequestMap,
downloadRequestsTranslator,
pollUserDownloadRequests,
showCompletedDownloadSnackbar,
loading: downloadRequestLoading,
} = useDownloadRequests();
const deviceFormTranslator = crossComponentTranslator(AddDeviceForm);
Expand Down Expand Up @@ -337,6 +338,7 @@
isAdmin,
isSuperuser,
currentUserId,
showCompletedDownloadSnackbar,
};
},
props: {
Expand Down Expand Up @@ -504,6 +506,11 @@
this.stopMainScroll(false);
}
},
isDownloading(newVal) {
if (newVal === false && this.isDownloaded) {
this.showCompletedDownloadSnackbar();
}
},
},
created() {
this.initializeState();
Expand Down