Merge pull request #4270 from crazyserver/MOBILE-4723

MOBILE-4723 my: Allow again showing myoverview in my courses page
main
Dani Palou 2024-12-18 15:59:55 +01:00 committed by GitHub
commit 22cb658788
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 6 deletions

View File

@ -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';
}
/**
@ -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;
}
/**

View File

@ -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();

View File

@ -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;
}
/**

View File

@ -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);