diff --git a/scripts/langindex.json b/scripts/langindex.json index db78fc2ed..b0020c991 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -45,7 +45,6 @@ "addon.block_myoverview.hiddencourses": "block_myoverview", "addon.block_myoverview.inprogress": "block_myoverview", "addon.block_myoverview.lastaccessed": "block_myoverview", - "addon.block_myoverview.morecourses": "block_myoverview", "addon.block_myoverview.nocourses": "block_myoverview", "addon.block_myoverview.past": "block_myoverview", "addon.block_myoverview.pluginname": "block_myoverview", @@ -1383,6 +1382,7 @@ "core.choose": "moodle", "core.choosedots": "moodle", "core.clearsearch": "local_moodlemobileapp", + "core.clearstoreddata": "local_moodlemobileapp", "core.clicktohideshow": "moodle", "core.clicktoseefull": "local_moodlemobileapp", "core.close": "repository", @@ -1436,6 +1436,7 @@ "core.course.availablespace": "local_moodlemobileapp", "core.course.cannotdeletewhiledownloading": "local_moodlemobileapp", "core.course.confirmdeletemodulefiles": "local_moodlemobileapp", + "core.course.confirmdeletestoreddata": "local_moodlemobileapp", "core.course.confirmdownload": "local_moodlemobileapp", "core.course.confirmdownloadunknownsize": "local_moodlemobileapp", "core.course.confirmdownloadzerosize": "local_moodlemobileapp", diff --git a/src/addon/block/myoverview/lang/en.json b/src/addon/block/myoverview/lang/en.json index 9d38164d8..7bca82636 100644 --- a/src/addon/block/myoverview/lang/en.json +++ b/src/addon/block/myoverview/lang/en.json @@ -6,7 +6,6 @@ "hiddencourses": "Removed from view", "inprogress": "In progress", "lastaccessed": "Last accessed", - "morecourses": "More courses", "nocourses": "No courses", "past": "Past", "pluginname": "Course overview", diff --git a/src/addon/mod/assign/components/index/addon-mod-assign-index.html b/src/addon/mod/assign/components/index/addon-mod-assign-index.html index ee087a9df..18284862e 100644 --- a/src/addon/mod/assign/components/index/addon-mod-assign-index.html +++ b/src/addon/mod/assign/components/index/addon-mod-assign-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/book/components/index/addon-mod-book-index.html b/src/addon/mod/book/components/index/addon-mod-book-index.html index ee1e5bbad..74ad51a52 100644 --- a/src/addon/mod/book/components/index/addon-mod-book-index.html +++ b/src/addon/mod/book/components/index/addon-mod-book-index.html @@ -9,7 +9,7 @@ - + diff --git a/src/addon/mod/choice/components/index/addon-mod-choice-index.html b/src/addon/mod/choice/components/index/addon-mod-choice-index.html index 5cc0b88b7..bdadfd1f2 100644 --- a/src/addon/mod/choice/components/index/addon-mod-choice-index.html +++ b/src/addon/mod/choice/components/index/addon-mod-choice-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/data/components/index/addon-mod-data-index.html b/src/addon/mod/data/components/index/addon-mod-data-index.html index af4a82ad6..c0a92a4ad 100644 --- a/src/addon/mod/data/components/index/addon-mod-data-index.html +++ b/src/addon/mod/data/components/index/addon-mod-data-index.html @@ -12,7 +12,7 @@ - + diff --git a/src/addon/mod/feedback/components/index/addon-mod-feedback-index.html b/src/addon/mod/feedback/components/index/addon-mod-feedback-index.html index c7edc940d..d4f10a815 100644 --- a/src/addon/mod/feedback/components/index/addon-mod-feedback-index.html +++ b/src/addon/mod/feedback/components/index/addon-mod-feedback-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/folder/components/index/addon-mod-folder-index.html b/src/addon/mod/folder/components/index/addon-mod-folder-index.html index 2aa7976f3..e56091080 100644 --- a/src/addon/mod/folder/components/index/addon-mod-folder-index.html +++ b/src/addon/mod/folder/components/index/addon-mod-folder-index.html @@ -6,7 +6,7 @@ - + diff --git a/src/addon/mod/forum/components/index/addon-mod-forum-index.html b/src/addon/mod/forum/components/index/addon-mod-forum-index.html index 31e15b3e0..4f00d77b0 100644 --- a/src/addon/mod/forum/components/index/addon-mod-forum-index.html +++ b/src/addon/mod/forum/components/index/addon-mod-forum-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html b/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html index 0c01a1288..475d5e969 100644 --- a/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html +++ b/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html @@ -14,7 +14,7 @@ - + diff --git a/src/addon/mod/h5pactivity/components/index/addon-mod-h5pactivity-index.html b/src/addon/mod/h5pactivity/components/index/addon-mod-h5pactivity-index.html index 23df4f6ad..cd0c7f9e8 100644 --- a/src/addon/mod/h5pactivity/components/index/addon-mod-h5pactivity-index.html +++ b/src/addon/mod/h5pactivity/components/index/addon-mod-h5pactivity-index.html @@ -8,7 +8,7 @@ - + diff --git a/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html b/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html index 9f767d27c..7d14a8a56 100644 --- a/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html +++ b/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html @@ -9,7 +9,7 @@ - + diff --git a/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html b/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html index 834abcf38..ebe107144 100644 --- a/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html +++ b/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/page/components/index/addon-mod-page-index.html b/src/addon/mod/page/components/index/addon-mod-page-index.html index d3d6c7726..783080214 100644 --- a/src/addon/mod/page/components/index/addon-mod-page-index.html +++ b/src/addon/mod/page/components/index/addon-mod-page-index.html @@ -6,7 +6,7 @@ - + diff --git a/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html b/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html index ec8685448..d7586c3ac 100644 --- a/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html +++ b/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/resource/components/index/addon-mod-resource-index.html b/src/addon/mod/resource/components/index/addon-mod-resource-index.html index e6aa1efff..f910fabfb 100644 --- a/src/addon/mod/resource/components/index/addon-mod-resource-index.html +++ b/src/addon/mod/resource/components/index/addon-mod-resource-index.html @@ -6,7 +6,7 @@ - + diff --git a/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html b/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html index cc16da2c2..b3e5d565e 100644 --- a/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html +++ b/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/survey/components/index/addon-mod-survey-index.html b/src/addon/mod/survey/components/index/addon-mod-survey-index.html index eb101c594..9b3531df3 100644 --- a/src/addon/mod/survey/components/index/addon-mod-survey-index.html +++ b/src/addon/mod/survey/components/index/addon-mod-survey-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/mod/wiki/components/index/addon-mod-wiki-index.html b/src/addon/mod/wiki/components/index/addon-mod-wiki-index.html index 44a57c1ca..f9a3da731 100644 --- a/src/addon/mod/wiki/components/index/addon-mod-wiki-index.html +++ b/src/addon/mod/wiki/components/index/addon-mod-wiki-index.html @@ -19,7 +19,7 @@ - + diff --git a/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html b/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html index f662c02ae..7e8daa461 100644 --- a/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html +++ b/src/addon/mod/workshop/components/index/addon-mod-workshop-index.html @@ -7,7 +7,7 @@ - + diff --git a/src/addon/storagemanager/pages/course-storage/course-storage.ts b/src/addon/storagemanager/pages/course-storage/course-storage.ts index f3ec571e1..7dace4b7b 100644 --- a/src/addon/storagemanager/pages/course-storage/course-storage.ts +++ b/src/addon/storagemanager/pages/course-storage/course-storage.ts @@ -20,7 +20,6 @@ import { CoreCourseHelperProvider } from '@core/course/providers/helper'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { TranslateService } from '@ngx-translate/core'; import { CoreConstants } from '@core/constants'; -import { CoreSitesProvider } from '@providers/sites'; /** * Page that displays the amount of file storage used by each activity on the course, and allows @@ -40,7 +39,6 @@ export class AddonStorageManagerCourseStoragePage { totalSize: number; constructor(navParams: NavParams, - private sitesProvider: CoreSitesProvider, private courseProvider: CoreCourseProvider, private prefetchDelegate: CoreCourseModulePrefetchDelegate, private courseHelperProvider: CoreCourseHelperProvider, @@ -102,7 +100,7 @@ export class AddonStorageManagerCourseStoragePage { */ async deleteForCourse(): Promise { try { - await this.domUtils.showDeleteConfirm('core.course.confirmdeletemodulefiles'); + await this.domUtils.showDeleteConfirm('core.course.confirmdeletestoreddata'); } catch (error) { if (!error.coreCanceled) { throw error; @@ -132,7 +130,7 @@ export class AddonStorageManagerCourseStoragePage { */ async deleteForSection(section: any): Promise { try { - await this.domUtils.showDeleteConfirm('core.course.confirmdeletemodulefiles'); + await this.domUtils.showDeleteConfirm('core.course.confirmdeletestoreddata'); } catch (error) { if (!error.coreCanceled) { throw error; @@ -162,7 +160,7 @@ export class AddonStorageManagerCourseStoragePage { } try { - await this.domUtils.showDeleteConfirm('core.course.confirmdeletemodulefiles'); + await this.domUtils.showDeleteConfirm('core.course.confirmdeletestoreddata'); } catch (error) { if (!error.coreCanceled) { throw error; @@ -186,13 +184,7 @@ export class AddonStorageManagerCourseStoragePage { const promises = []; modules.forEach((module) => { // Remove the files. - const promise = this.prefetchDelegate.removeModuleFiles(module, this.course.id).then(() => { - const handler = this.prefetchDelegate.getPrefetchHandlerFor(module); - if (handler) { - - return this.sitesProvider.getCurrentSite().deleteComponentFromCache(handler.component, module.id); - } - }).then(() => { + const promise = this.courseHelperProvider.removeModuleStoredData(module, this.course.id).then(() => { // When the files and cache are removed, update the size. module.parentSection.totalSize -= module.totalSize; this.totalSize -= module.totalSize; diff --git a/src/addon/storagemanager/pages/courses-storage/courses-storage.ts b/src/addon/storagemanager/pages/courses-storage/courses-storage.ts index 05b5aa709..5beb27b09 100644 --- a/src/addon/storagemanager/pages/courses-storage/courses-storage.ts +++ b/src/addon/storagemanager/pages/courses-storage/courses-storage.ts @@ -92,7 +92,7 @@ export class AddonStorageManagerCoursesStoragePage { */ async deleteCompletelyDownloadedCourses(): Promise { try { - await CoreDomUtils.instance.showDeleteConfirm('core.course.confirmdeletemodulefiles'); + await CoreDomUtils.instance.showDeleteConfirm('core.course.confirmdeletestoreddata'); } catch (error) { if (!error.coreCanceled) { throw error; @@ -122,7 +122,7 @@ export class AddonStorageManagerCoursesStoragePage { */ async deleteCourse(course: DownloadedCourse): Promise { try { - await CoreDomUtils.instance.showDeleteConfirm('core.course.confirmdeletemodulefiles'); + await CoreDomUtils.instance.showDeleteConfirm('core.course.confirmdeletestoreddata'); } catch (error) { if (!error.coreCanceled) { throw error; @@ -206,7 +206,7 @@ export class AddonStorageManagerCoursesStoragePage { const sections = await CoreCourse.instance.getSections(courseId); const modules = CoreArray.flatten(sections.map((section) => section.modules)); const promisedModuleSizes = modules.map(async (module) => { - const size = await CoreCourseModulePrefetch.instance.getModuleDownloadedSize(module, courseId); + const size = await CoreCourseModulePrefetch.instance.getModuleStoredSize(module, courseId); return isNaN(size) ? 0 : size; }); diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 5be7a28c6..d5fd154d5 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -45,7 +45,6 @@ "addon.block_myoverview.hiddencourses": "Removed from view", "addon.block_myoverview.inprogress": "In progress", "addon.block_myoverview.lastaccessed": "Last accessed", - "addon.block_myoverview.morecourses": "More courses", "addon.block_myoverview.nocourses": "No courses", "addon.block_myoverview.past": "Past", "addon.block_myoverview.pluginname": "Course overview", @@ -1384,6 +1383,7 @@ "core.choose": "Choose", "core.choosedots": "Choose...", "core.clearsearch": "Clear search", + "core.clearstoreddata": "Clear storage {{$a}}", "core.clicktohideshow": "Click to expand or collapse", "core.clicktoseefull": "Click to see full contents.", "core.close": "Close", @@ -1437,6 +1437,7 @@ "core.course.availablespace": " You currently have about {{available}} free space.", "core.course.cannotdeletewhiledownloading": "Files cannot be deleted while the activity is being downloaded. Please wait for the download to finish.", "core.course.confirmdeletemodulefiles": "Are you sure you want to delete these files?", + "core.course.confirmdeletestoreddata": "Are you sure you want to delete the stored data?", "core.course.confirmdownload": "You are about to download {{size}}.{{availableSpace}} Are you sure you want to continue?", "core.course.confirmdownloadunknownsize": "It was not possible to calculate the size of the download.{{availableSpace}} Are you sure you want to continue?", "core.course.confirmdownloadzerosize": "You are about to start downloading.{{availableSpace}} Are you sure you want to continue?", diff --git a/src/classes/site.ts b/src/classes/site.ts index 14bbf40fb..10c9c3e27 100644 --- a/src/classes/site.ts +++ b/src/classes/site.ts @@ -1107,10 +1107,10 @@ export class CoreSite { * @param componentId Optional component id (if not included, returns sum for whole component) * @return Promise resolved when we have calculated the size */ - getComponentCacheSize(component: string, componentId?: string): Promise { - const params = [component]; + getComponentCacheSize(component: string, componentId?: number): Promise { + const params: any[] = [component]; let extraClause = ''; - if (componentId) { + if (componentId !== undefined && componentId !== null) { params.push(componentId); extraClause = ' AND componentId = ?'; } @@ -1200,7 +1200,7 @@ export class CoreSite { * @param componentId Component id. * @return Promise resolved when the entries are deleted. */ - async deleteComponentFromCache(component: string, componentId?: string): Promise { + async deleteComponentFromCache(component: string, componentId?: number): Promise { if (!component) { return; } diff --git a/src/core/course/lang/en.json b/src/core/course/lang/en.json index 69cbe5cf9..2a74a13a0 100644 --- a/src/core/course/lang/en.json +++ b/src/core/course/lang/en.json @@ -7,6 +7,7 @@ "availablespace": " You currently have about {{available}} free space.", "cannotdeletewhiledownloading": "Files cannot be deleted while the activity is being downloaded. Please wait for the download to finish.", "confirmdeletemodulefiles": "Are you sure you want to delete these files?", + "confirmdeletestoreddata": "Are you sure you want to delete the stored data?", "confirmdownload": "You are about to download {{size}}.{{availableSpace}} Are you sure you want to continue?", "confirmdownloadunknownsize": "It was not possible to calculate the size of the download.{{availableSpace}} Are you sure you want to continue?", "confirmdownloadzerosize": "You are about to start downloading.{{availableSpace}} Are you sure you want to continue?", diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index 99e181b96..bc1d52fef 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -419,16 +419,11 @@ export class CoreCourseHelperProvider { try { - await this.domUtils.showDeleteConfirm('core.course.confirmdeletemodulefiles'); + await this.domUtils.showDeleteConfirm('core.course.confirmdeletestoreddata'); modal = this.domUtils.showModalLoading(); - await this.prefetchDelegate.removeModuleFiles(module, courseId); - - const handler = this.prefetchDelegate.getPrefetchHandlerFor(module); - if (handler) { - await this.sitesProvider.getCurrentSite().deleteComponentFromCache(handler.component, String(module.id)); - } + await this.removeModuleStoredData(module, courseId); done && done(); @@ -859,7 +854,7 @@ export class CoreCourseHelperProvider { if (typeof instance.contextFileStatusObserver == 'undefined' && component) { // Debounce the update size function to prevent too many calls when downloading or deleting a whole activity. const debouncedUpdateSize = this.utils.debounce(() => { - this.prefetchDelegate.getModuleDownloadedSize(module, courseId).then((moduleSize) => { + this.prefetchDelegate.getModuleStoredSize(module, courseId).then((moduleSize) => { instance.size = moduleSize > 0 ? this.textUtils.bytesToSize(moduleSize, 2) : 0; }); }, 1000); @@ -1630,12 +1625,32 @@ export class CoreCourseHelperProvider { const modules = CoreArray.flatten(sections.map((section) => section.modules)); await Promise.all( - modules.map((module) => this.prefetchDelegate.removeModuleFiles(module, courseId)), + modules.map((module) => this.removeModuleStoredData(module, courseId)), ); await this.courseProvider.setCourseStatus(courseId, CoreConstants.NOT_DOWNLOADED); } + /** + * Remove module stored data. + * + * @param module Module to remove the files. + * @param courseId Course ID the module belongs to. + * @return Promise resolved when done. + */ + async removeModuleStoredData(module: any, courseId: number): Promise { + const promises = []; + + promises.push(this.prefetchDelegate.removeModuleFiles(module, courseId)); + + const handler = this.prefetchDelegate.getPrefetchHandlerFor(module); + if (handler) { + promises.push(this.sitesProvider.getCurrentSite().deleteComponentFromCache(handler.component, module.id)); + } + + await Promise.all(promises); + } + } export class CoreCourseHelper extends makeSingleton(CoreCourseHelperProvider) {} diff --git a/src/core/courses/components/course-progress/course-progress.ts b/src/core/courses/components/course-progress/course-progress.ts index 88923c044..1d30aa267 100644 --- a/src/core/courses/components/course-progress/course-progress.ts +++ b/src/core/courses/components/course-progress/course-progress.ts @@ -163,7 +163,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy { */ async deleteCourse(): Promise { try { - await this.domUtils.showDeleteConfirm('core.course.confirmdeletemodulefiles'); + await this.domUtils.showDeleteConfirm('core.course.confirmdeletestoreddata'); } catch (error) { if (!error.coreCanceled) { throw error; diff --git a/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html b/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html index a601f05c3..54836ba2e 100644 --- a/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html +++ b/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html @@ -5,7 +5,7 @@ - + diff --git a/src/lang/en.json b/src/lang/en.json index f00f084d3..23d49ca72 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -26,6 +26,7 @@ "choose": "Choose", "choosedots": "Choose...", "clearsearch": "Clear search", + "clearstoreddata": "Clear storage {{$a}}", "clicktohideshow": "Click to expand or collapse", "clicktoseefull": "Click to see full contents.", "close": "Close",