forked from CIT/Vmeda.Online
		
	Merge pull request #2856 from dpalou/MOBILE-3320
MOBILE-3320 dashboard: Fix download issues in recent access courses
This commit is contained in:
		
						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,42 +374,45 @@ 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';
 | 
			
		||||
 | 
			
		||||
        // Get the sections first if needed.
 | 
			
		||||
        if (!sections) {
 | 
			
		||||
            sections = await CoreCourse.getSections(course.id, false, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            // Get the sections first if needed.
 | 
			
		||||
            if (!sections) {
 | 
			
		||||
                sections = await CoreCourse.getSections(course.id, false, true);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Confirm the download.
 | 
			
		||||
            await this.confirmDownloadSizeSection(course.id, undefined, sections, true);
 | 
			
		||||
 | 
			
		||||
            // User confirmed, get the course handlers if needed.
 | 
			
		||||
            if (!courseHandlers) {
 | 
			
		||||
                courseHandlers = await CoreCourseOptionsDelegate.getHandlersToDisplay(course);
 | 
			
		||||
            }
 | 
			
		||||
            if (!menuHandlers) {
 | 
			
		||||
                menuHandlers = await CoreCourseOptionsDelegate.getMenuHandlersToDisplay(course);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Now we have all the data, download the course.
 | 
			
		||||
            await this.prefetchCourse(course, sections, courseHandlers, menuHandlers, siteId);
 | 
			
		||||
 | 
			
		||||
            // Download successful.
 | 
			
		||||
            data.downloadSucceeded = true;
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
            // User cancelled or there was an error calculating the size.
 | 
			
		||||
            // User cancelled or there was an error.
 | 
			
		||||
            data.icon = initialIcon;
 | 
			
		||||
            data.statusTranslatable = initialStatus;
 | 
			
		||||
            data.status = initialStatus;
 | 
			
		||||
            data.statusTranslatable = initialStatusTranslatable;
 | 
			
		||||
 | 
			
		||||
            throw error;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // User confirmed, get the course handlers if needed.
 | 
			
		||||
        if (!courseHandlers) {
 | 
			
		||||
            courseHandlers = await CoreCourseOptionsDelegate.getHandlersToDisplay(course);
 | 
			
		||||
        }
 | 
			
		||||
        if (!menuHandlers) {
 | 
			
		||||
            menuHandlers = await CoreCourseOptionsDelegate.getMenuHandlersToDisplay(course);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Now we have all the data, download the course.
 | 
			
		||||
        await this.prefetchCourse(course, sections, courseHandlers, menuHandlers, siteId);
 | 
			
		||||
 | 
			
		||||
        // Download successful.
 | 
			
		||||
        data.downloadSucceeded = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user