Merge pull request #3192 from dpalou/MOBILE-4002
MOBILE-4002 dashboard: Check new setting to disable dashboardmain
commit
cb2d2d1813
|
@ -15,6 +15,8 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreBlockDelegate } from '@features/block/services/block-delegate';
|
||||
import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreCoursesDashboard } from '../dashboard';
|
||||
|
||||
|
@ -45,40 +47,25 @@ export class CoreDashboardHomeHandlerService implements CoreMainMenuHomeHandler
|
|||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
async isEnabledForSite(siteId?: string): Promise<boolean> {
|
||||
const promises: Promise<void>[] = [];
|
||||
let blocksEnabled = false;
|
||||
let dashboardAvailable = false;
|
||||
let dashboardEnabled = false;
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
// Check if blocks and 3.6 dashboard is enabled.
|
||||
promises.push(CoreBlockDelegate.areBlocksDisabled(siteId).then((disabled) => {
|
||||
blocksEnabled = !disabled;
|
||||
const [blocksDisabled, dashboardDisabled, dashboardAvailable, dashboardConfig] = await Promise.all([
|
||||
CoreBlockDelegate.areBlocksDisabled(site.getId()),
|
||||
CoreCoursesDashboard.isDisabled(site.getId()),
|
||||
CoreCoursesDashboard.isAvailable(site.getId()),
|
||||
CoreUtils.ignoreErrors(site.getConfig('enabledashboard'), '1'),
|
||||
]);
|
||||
const dashboardEnabled = !dashboardDisabled && dashboardConfig !== '0';
|
||||
|
||||
return;
|
||||
}));
|
||||
|
||||
promises.push(CoreCoursesDashboard.isDisabled(siteId).then((disabled) => {
|
||||
dashboardEnabled = !disabled;
|
||||
|
||||
return;
|
||||
}));
|
||||
|
||||
promises.push(CoreCoursesDashboard.isAvailable(siteId).then((available) => {
|
||||
dashboardAvailable = available;
|
||||
|
||||
return;
|
||||
}));
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
if (dashboardAvailable && dashboardEnabled && blocksEnabled) {
|
||||
if (dashboardAvailable && dashboardEnabled && !blocksDisabled) {
|
||||
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, siteId);
|
||||
|
||||
return CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks) || CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);
|
||||
}
|
||||
|
||||
// Dashboard is enabled but not available, we will fake blocks.
|
||||
return dashboardEnabled && blocksEnabled;
|
||||
return dashboardEnabled && !blocksDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue