Merge pull request #2856 from dpalou/MOBILE-3320
MOBILE-3320 dashboard: Fix download issues in recent access coursesmain
commit
6700f92a53
|
@ -221,7 +221,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
|||
const initialIcon = this.prefetchCoursesData.icon;
|
||||
|
||||
try {
|
||||
return CoreCourseHelper.prefetchCourses(this.courses, this.prefetchCoursesData);
|
||||
await CoreCourseHelper.prefetchCourses(this.courses, this.prefetchCoursesData);
|
||||
} catch (error) {
|
||||
if (!this.isDestroyed) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true);
|
||||
|
|
|
@ -374,28 +374,23 @@ export class CoreCourseHelperProvider {
|
|||
menuHandlers?: CoreCourseOptionsMenuHandlerToDisplay[],
|
||||
): Promise<void> {
|
||||
const initialIcon = data.icon;
|
||||
const initialStatus = data.statusTranslatable;
|
||||
const initialStatus = data.status;
|
||||
const initialStatusTranslatable = data.statusTranslatable;
|
||||
const siteId = CoreSites.getCurrentSiteId();
|
||||
|
||||
data.downloadSucceeded = false;
|
||||
data.icon = CoreConstants.ICON_DOWNLOADING;
|
||||
data.status = CoreConstants.DOWNLOADING;
|
||||
data.statusTranslatable = 'core.downloading';
|
||||
|
||||
try {
|
||||
// Get the sections first if needed.
|
||||
if (!sections) {
|
||||
sections = await CoreCourse.getSections(course.id, false, true);
|
||||
}
|
||||
|
||||
try {
|
||||
// Confirm the download.
|
||||
await this.confirmDownloadSizeSection(course.id, undefined, sections, true);
|
||||
} catch (error) {
|
||||
// User cancelled or there was an error calculating the size.
|
||||
data.icon = initialIcon;
|
||||
data.statusTranslatable = initialStatus;
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
// User confirmed, get the course handlers if needed.
|
||||
if (!courseHandlers) {
|
||||
|
@ -410,6 +405,14 @@ export class CoreCourseHelperProvider {
|
|||
|
||||
// Download successful.
|
||||
data.downloadSucceeded = true;
|
||||
} catch (error) {
|
||||
// User cancelled or there was an error.
|
||||
data.icon = initialIcon;
|
||||
data.status = initialStatus;
|
||||
data.statusTranslatable = initialStatusTranslatable;
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
[statusTranslatable]="prefetchCourseData.statusTranslatable"
|
||||
canTrustDownload="false"
|
||||
[loading]="prefetchCourseData.loading"
|
||||
action="prefetchCourse()"></core-download-refresh>
|
||||
(action)="prefetchCourse()"></core-download-refresh>
|
||||
</div>
|
||||
|
||||
<div class="core-button-spinner" *ngIf="courseOptionMenuEnabled" slot="end">
|
||||
|
|
|
@ -107,8 +107,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
|
|||
// Determine course prefetch icon.
|
||||
const status = await CoreCourse.getCourseStatus(this.course.id);
|
||||
|
||||
this.prefetchCourseData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
|
||||
this.courseStatus = status;
|
||||
this.updateCourseStatus(status);
|
||||
|
||||
if (this.prefetchCourseData.loading) {
|
||||
// Course is being downloaded. Get the download promise.
|
||||
|
|
Loading…
Reference in New Issue