From 5e9bcb4b45af5412d5705701a495f4a8132cc80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 18 Dec 2024 14:46:55 +0100 Subject: [PATCH] MOBILE-4723 my: Allow again showing myoverview in my courses page --- src/core/classes/delegate.ts | 6 +++--- src/core/features/block/components/block/block.ts | 2 +- src/core/features/block/services/block-delegate.ts | 3 ++- src/core/features/courses/pages/my/my.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/classes/delegate.ts b/src/core/classes/delegate.ts index 74bb8bce0..d58471b63 100644 --- a/src/core/classes/delegate.ts +++ b/src/core/classes/delegate.ts @@ -191,9 +191,9 @@ export class CoreDelegate { * @returns Function returned value or default value. */ protected hasFunction(handlerName: string, fnName: string, onlyEnabled: boolean = true): boolean { - const handler = onlyEnabled ? this.enabledHandlers[handlerName] : this.handlers[handlerName]; + const handler = this.getHandler(handlerName, onlyEnabled); - return handler && typeof handler[fnName] == 'function'; + return handler && typeof handler[fnName] === 'function'; } /** @@ -204,7 +204,7 @@ export class CoreDelegate { * @returns If the handler is registered or not. */ hasHandler(name: string, enabled: boolean = false): boolean { - return enabled ? this.enabledHandlers[name] !== undefined : this.handlers[name] !== undefined; + return this.getHandler(name, enabled) !== undefined; } /** diff --git a/src/core/features/block/components/block/block.ts b/src/core/features/block/components/block/block.ts index 46308a7b8..a5efbace0 100644 --- a/src/core/features/block/components/block/block.ts +++ b/src/core/features/block/components/block/block.ts @@ -101,7 +101,7 @@ export class CoreBlockComponent implements OnChanges, OnDestroy { } /** - * On destroy of the component, clear up any subscriptions. + * @inheritdoc */ ngOnDestroy(): void { this.blockSubscription?.unsubscribe(); diff --git a/src/core/features/block/services/block-delegate.ts b/src/core/features/block/services/block-delegate.ts index 4ec118e67..0f9d0ddc2 100644 --- a/src/core/features/block/services/block-delegate.ts +++ b/src/core/features/block/services/block-delegate.ts @@ -114,7 +114,8 @@ export class CoreBlockDelegateService extends CoreDelegate { * @inheritdoc */ async isEnabled(): Promise { - return !this.areBlocksDisabledInSite(); + // Always return true, to allow displaying my overview even if all blocks are disabled, to avoid having an empty My Courses. + return true; } /** diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts index f0e1d978d..cd9092777 100644 --- a/src/core/features/courses/pages/my/my.ts +++ b/src/core/features/courses/pages/my/my.ts @@ -120,7 +120,7 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { ); // 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.loadedBlock = blocks.mainBlocks.concat(blocks.sideBlocks).find((block) => block.name === 'myoverview'); this.hasSideBlocks = supportsMyParam && CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks); await CoreWait.nextTicks(2);