MOBILE-3947 blocks: Check if blocks are disabled when loading filters

main
Pau Ferrer Ocaña 2024-03-06 12:28:47 +01:00
parent d7d4772252
commit a05aba6bef
2 changed files with 6 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreCourse, CoreCourseBlock } from '@features/course/services/course';
import { CoreBlockDelegate } from './block-delegate';
import { makeSingleton } from '@singletons';
import { CoreSite } from '@classes/sites/site';
/**
* Service that provides helper functions for blocks.
@ -26,10 +27,11 @@ export class CoreBlockHelperProvider {
/**
* Return if it get course blocks options is enabled for the current site.
*
* @param site Site. If not defined, current site.
* @returns true if enabled, false otherwise.
*/
canGetCourseBlocks(): boolean {
return CoreCourse.canGetCourseBlocks() && !CoreBlockDelegate.areBlocksDisabledInCourses();
canGetCourseBlocks(site?: CoreSite): boolean {
return CoreCourse.canGetCourseBlocks(site) && !CoreBlockDelegate.areBlocksDisabledInCourses(site);
}
/**

View File

@ -32,6 +32,7 @@ import { CoreLogger } from '@singletons/logger';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseHelper } from '@features/course/services/course-helper';
import { firstValueFrom } from 'rxjs';
import { CoreBlockHelper } from '@features/block/services/block-helper';
/**
* Helper service to provide filter functionalities.
@ -246,7 +247,7 @@ export class CoreFilterHelperProvider {
const getFilters = () => this.getCourseContexts(instanceId, siteId);
return await this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site);
} else if (contextLevel == 'block' && courseId && CoreCourse.canGetCourseBlocks(site)) {
} else if (contextLevel == 'block' && courseId && CoreBlockHelper.canGetCourseBlocks(site)) {
// Get all the course blocks filters with a single call to decrease number of WS calls.
const getFilters = () => this.getBlocksContexts(courseId, siteId);