Skip to content

Commit

Permalink
Merge pull request #4270 from crazyserver/MOBILE-4723
Browse files Browse the repository at this point in the history
MOBILE-4723 my: Allow again showing myoverview in my courses page
  • Loading branch information
dpalou authored Dec 18, 2024
2 parents 0af6865 + 5e9bcb4 commit 22cb658
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/core/classes/delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ export class CoreDelegate<HandlerType extends CoreDelegateHandler> {
* @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';
}

/**
Expand All @@ -204,7 +204,7 @@ export class CoreDelegate<HandlerType extends CoreDelegateHandler> {
* @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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/block/components/block/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/core/features/block/services/block-delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export class CoreBlockDelegateService extends CoreDelegate<CoreBlockHandler> {
* @inheritdoc
*/
async isEnabled(): Promise<boolean> {
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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/courses/pages/my/my.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 22cb658

Please sign in to comment.