MOBILE-3814 storage: Fix course prefetch
parent
7736d899a9
commit
54deab86f8
|
@ -549,7 +549,14 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
|
|||
* Prefetch the whole course.
|
||||
*/
|
||||
async prefetchCourse(): Promise<void> {
|
||||
const course = await CoreCourses.getCourse(this.courseId);
|
||||
const courses = await CoreCourses.getUserCourses(true);
|
||||
let course = courses.find((course) => course.id == this.courseId);
|
||||
if (!course) {
|
||||
course = await CoreCourses.getCourse(this.courseId);
|
||||
}
|
||||
if (!course) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await CoreCourseHelper.confirmAndPrefetchCourse(
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
{{ 'core.settings.spaceusagehelp' | translate }}
|
||||
</p>
|
||||
</ion-label>
|
||||
<ion-button fill="clear" color="danger" slot="end" (click)="deleteSiteStorage()"
|
||||
<ion-button fill="clear" color="danger" slot="end" (click)="deleteSiteStorage($event)"
|
||||
[hidden]="spaceUsage.spaceUsage! + spaceUsage.cacheEntries! <= 0"
|
||||
[attr.aria-label]="'core.settings.deletesitefilestitle' | translate" fill="outline">
|
||||
<ion-icon name="fas-trash" slot="icon-only" aria-hidden="true"></ion-icon>
|
||||
|
@ -31,8 +31,8 @@
|
|||
<h2 class="ion-text-wrap">{{ 'addon.storagemanager.coursesspaceusage' | translate }}</h2>
|
||||
<ion-badge color="light">{{ totalSize | coreBytesToSize }}</ion-badge>
|
||||
</ion-label>
|
||||
<ion-button slot="end" (click)="deleteCompletelyDownloadedCourses()" [disabled]="completelyDownloadedCourses.length === 0"
|
||||
color="danger" fill="outline">
|
||||
<ion-button slot="end" (click)="deleteCompletelyDownloadedCourses($event)"
|
||||
[disabled]="completelyDownloadedCourses.length === 0" color="danger" fill="outline">
|
||||
<ion-icon name="fas-trash" slot="icon-only" ariaLabel="{{ 'addon.storagemanager.deletecourses' | translate }}">
|
||||
</ion-icon>
|
||||
</ion-button>
|
||||
|
@ -55,7 +55,8 @@
|
|||
{{ course.totalSize | coreBytesToSize }}
|
||||
</ion-badge>
|
||||
</ion-label>
|
||||
<ion-button slot="end" (click)="deleteCourse(course)" [disabled]="course.isDownloading" color="danger" fill="clear">
|
||||
<ion-button slot="end" (click)="deleteCourse($event, course)" [disabled]="course.isDownloading" color="danger"
|
||||
fill="clear">
|
||||
<ion-icon name="fas-trash" slot="icon-only"
|
||||
[attr.aria-label]="'addon.storagemanager.deletedatafrom' | translate: { name: course.displayname }">
|
||||
</ion-icon>
|
||||
|
|
|
@ -103,8 +103,13 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy
|
|||
|
||||
/**
|
||||
* Delete all courses that have been downloaded.
|
||||
*
|
||||
* @param event: Event Object.
|
||||
*/
|
||||
async deleteCompletelyDownloadedCourses(): Promise<void> {
|
||||
async deleteCompletelyDownloadedCourses(event: Event): Promise<void> {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
try {
|
||||
await CoreDomUtils.showDeleteConfirm('core.course.confirmdeletestoreddata');
|
||||
} catch (error) {
|
||||
|
@ -132,9 +137,13 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy
|
|||
/**
|
||||
* Delete course.
|
||||
*
|
||||
* @param event: Event Object.
|
||||
* @param course Course to delete.
|
||||
*/
|
||||
async deleteCourse(course: DownloadedCourse): Promise<void> {
|
||||
async deleteCourse(event: Event, course: DownloadedCourse): Promise<void> {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
try {
|
||||
await CoreDomUtils.showDeleteConfirm('core.course.confirmdeletestoreddata');
|
||||
} catch (error) {
|
||||
|
@ -242,9 +251,12 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy
|
|||
/**
|
||||
* Deletes files of a site and the tables that can be cleared.
|
||||
*
|
||||
* @param siteData Site object with space usage.
|
||||
* @param event: Event Object.
|
||||
*/
|
||||
async deleteSiteStorage(): Promise<void> {
|
||||
async deleteSiteStorage(event: Event): Promise<void> {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
try {
|
||||
const siteName = CoreSites.getRequiredCurrentSite().getSiteName();
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ export class CoreSettingsHelperProvider {
|
|||
const title = Translate.instant('core.settings.deletesitefilestitle');
|
||||
const message = Translate.instant('core.settings.deletesitefiles', { sitename: siteName });
|
||||
|
||||
await CoreDomUtils.showConfirm(message, title);
|
||||
await CoreDomUtils.showConfirm(message, title, Translate.instant('core.delete'));
|
||||
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
|
|
Loading…
Reference in New Issue