From 585f6696419df14912da7bf27b619289fdd3bd78 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 2 Jun 2022 16:10:31 +0200 Subject: [PATCH 01/17] MOBILE-4089 forum: Fix infinite loop in getDiscussionsInPages --- src/addons/mod/forum/services/forum.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/addons/mod/forum/services/forum.ts b/src/addons/mod/forum/services/forum.ts index 9c2e1c989..adf94722f 100644 --- a/src/addons/mod/forum/services/forum.ts +++ b/src/addons/mod/forum/services/forum.ts @@ -845,8 +845,6 @@ export class AddonModForumProvider { forumId: number, options: AddonModForumGetDiscussionsInPagesOptions = {}, ): Promise<{ discussions: AddonModForumDiscussion[]; error: boolean }> { - options.page = options.page || 0; - const result = { discussions: [] as AddonModForumDiscussion[], error: false, @@ -859,7 +857,10 @@ export class AddonModForumProvider { const getPage = (page: number): Promise<{ discussions: AddonModForumDiscussion[]; error: boolean }> => // Get page discussions. - this.getDiscussions(forumId, options).then((response) => { + this.getDiscussions(forumId, { + ...options, + page, + }).then((response) => { result.discussions = result.discussions.concat(response.discussions); numPages--; @@ -876,7 +877,7 @@ export class AddonModForumProvider { }) ; - return getPage(options.page); + return getPage(options.page ?? 0); } /** From d5c440b97d679ef429985c9577a8c0ed47a5802e Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 2 Jun 2022 16:21:32 +0200 Subject: [PATCH 02/17] MOBILE-4089 forum: Don't fetch all pages when invalidating data --- src/addons/mod/forum/services/forum.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/addons/mod/forum/services/forum.ts b/src/addons/mod/forum/services/forum.ts index adf94722f..93bb01e2d 100644 --- a/src/addons/mod/forum/services/forum.ts +++ b/src/addons/mod/forum/services/forum.ts @@ -917,7 +917,7 @@ export class AddonModForumProvider { .getDiscussionsInPages(forum.id, { cmId: forum.cmid, sortOrder: sortOrder.value, - readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE, + readingStrategy: CoreSitesReadingStrategy.ONLY_CACHE, }) .then((response) => { // Now invalidate the WS calls. From 077fd682e6040662552050fceff8899f0c31c42e Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 2 Jun 2022 16:35:06 +0200 Subject: [PATCH 03/17] MOBILE-4089 forum: Fix wrong parameter passed to prefetchModule --- .../storagemanager/pages/course-storage/course-storage.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/addons/storagemanager/pages/course-storage/course-storage.html b/src/addons/storagemanager/pages/course-storage/course-storage.html index 84fb399a2..8d2a1b7b3 100644 --- a/src/addons/storagemanager/pages/course-storage/course-storage.html +++ b/src/addons/storagemanager/pages/course-storage/course-storage.html @@ -128,7 +128,7 @@ + (action)="prefetchModule(module, $event)"> From a2e512de2662179629b42ba69bbed0f637bf0da1 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 8 Jun 2022 10:38:42 +0200 Subject: [PATCH 04/17] MOBILE-4091 mycourses: Fix mypage error and empty page --- src/core/classes/site.ts | 2 +- .../features/block/services/block-delegate.ts | 4 +++- src/core/features/courses/pages/my/my.ts | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 43f058af3..c8781f9f7 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -104,7 +104,7 @@ export class CoreSite { '3.9': 2020061500, '3.10': 2020110900, '3.11': 2021051700, - '4.0': 2021100300, // @todo [4.0] replace with right value when released. Using a tmp value to be able to test new things. + '4.0': 2022041900, }; // Possible cache update frequencies. diff --git a/src/core/features/block/services/block-delegate.ts b/src/core/features/block/services/block-delegate.ts index 8a5b28b8d..5a2aa3d81 100644 --- a/src/core/features/block/services/block-delegate.ts +++ b/src/core/features/block/services/block-delegate.ts @@ -195,7 +195,9 @@ export class CoreBlockDelegateService extends CoreDelegate { * @return Whether is enabled or disabled in site. */ protected isFeatureDisabled(handler: CoreBlockHandler, site: CoreSite): boolean { - return this.areBlocksDisabledInSite(site) || super.isFeatureDisabled(handler, site); + // Allow displaying my overview even if all blocks are disabled, to avoid having an empty My Courses. + return (this.areBlocksDisabledInSite(site) && handler.blockName !== 'myoverview') || + super.isFeatureDisabled(handler, site); } /** diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts index 3f8b321a0..ef5ae03a4 100644 --- a/src/core/features/courses/pages/my/my.ts +++ b/src/core/features/courses/pages/my/my.ts @@ -18,6 +18,7 @@ import { AsyncComponent } from '@classes/async-component'; import { PageLoadsManager } from '@classes/page-loads-manager'; import { CorePromisedValue } from '@classes/promised-value'; import { CoreBlockComponent } from '@features/block/components/block/block'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; import { CoreCourseBlock } from '@features/course/services/course'; import { CoreCoursesDashboard, CoreCoursesDashboardProvider } from '@features/courses/services/dashboard'; import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager'; @@ -98,22 +99,30 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy, AsyncCompone const available = await CoreCoursesDashboard.isAvailable(); const disabled = await CoreCourses.isMyCoursesDisabled(); + const supportsMyParam = !!CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('4.0'); + if (available && !disabled) { try { const blocks = await loadWatcher.watchRequest( CoreCoursesDashboard.getDashboardBlocksObservable({ - myPage: this.myPageCourses, + myPage: supportsMyParam ? this.myPageCourses : undefined, readingStrategy: loadWatcher.getReadingStrategy(), }), ); // My overview block should always be in main blocks, but check side blocks too just in case. this.loadedBlock = blocks.mainBlocks.concat(blocks.sideBlocks).find((block) => block.name == 'myoverview'); - this.hasSideBlocks = blocks.sideBlocks.length > 0; + this.hasSideBlocks = supportsMyParam && CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks); await CoreUtils.nextTicks(2); this.myOverviewBlock = this.block?.dynamicComponent?.instance as AddonBlockMyOverviewComponent; + + if (!this.loadedBlock && !supportsMyParam) { + // In old sites, display the block even if not found in Dashboard. + // This is because the "My courses" page doesn't exist in the site so it can't be configured. + this.loadFallbackBlock(); + } } catch (error) { CoreDomUtils.showErrorModal(error); @@ -121,10 +130,9 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy, AsyncCompone this.loadFallbackBlock(); } } else if (!available) { - // WS not available, or my courses page not available. show fallback block. + // WS not available, show fallback block. this.loadFallbackBlock(); } else { - // Disabled. this.loadedBlock = undefined; } From 689a36ac12028bee1b3d1e9396ee105b98af642a Mon Sep 17 00:00:00 2001 From: Anastasios Bithas Date: Sat, 11 Jun 2022 17:48:33 +0300 Subject: [PATCH 05/17] MOBILE-4092 courses: Fix access to hidden courses --- .../course-list-item/core-courses-course-list-item.html | 2 +- .../components/course-list-item/course-list-item.scss | 5 +++++ .../course-progress/core-courses-course-progress.html | 2 +- .../courses/components/course-progress/course-progress.scss | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html b/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html index e8d9a2749..954a0a190 100644 --- a/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html +++ b/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html @@ -28,7 +28,7 @@ + [class.core-course-disabled]="course.visible == 0"> - + + + + + {{ 'core.course.hiddenfromstudents' | translate }} + +