MOBILE-4067 home: Display Dashboard if WS call fails
parent
0b1a395bb5
commit
8360f5793d
|
@ -20,6 +20,7 @@ import { CoreCoursesDashboard, CoreCoursesDashboardProvider } from '@features/co
|
|||
import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreCourses } from '../../services/courses';
|
||||
|
@ -90,7 +91,9 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
|
|||
await CoreUtils.nextTicks(2);
|
||||
|
||||
this.myOverviewBlock = this.block?.dynamicComponent?.instance as AddonBlockMyOverviewComponent;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModal(error);
|
||||
|
||||
// Cannot get the blocks, just show the block if needed.
|
||||
this.loadFallbackBlock();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@feat
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreCoursesDashboard } from '../dashboard';
|
||||
|
||||
/**
|
||||
|
@ -30,6 +31,11 @@ export class CoreDashboardHomeHandlerService implements CoreMainMenuHomeHandler
|
|||
|
||||
name = 'CoreCoursesDashboard';
|
||||
priority = 1200;
|
||||
logger: CoreLogger;
|
||||
|
||||
constructor() {
|
||||
this.logger = CoreLogger.getInstance('CoreDashboardHomeHandlerService');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
|
@ -59,9 +65,17 @@ export class CoreDashboardHomeHandlerService implements CoreMainMenuHomeHandler
|
|||
const dashboardEnabled = !dashboardDisabled && dashboardConfig !== '0';
|
||||
|
||||
if (dashboardAvailable && dashboardEnabled && !blocksDisabled) {
|
||||
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, siteId);
|
||||
try {
|
||||
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, siteId);
|
||||
|
||||
return CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks) || CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);
|
||||
return CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks) ||
|
||||
CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);
|
||||
} catch (error) {
|
||||
// Error getting blocks, assume it's enabled.
|
||||
this.logger.error('Error getting Dashboard blocks', error);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Dashboard is enabled but not available, we will fake blocks.
|
||||
|
|
Loading…
Reference in New Issue