Skip to content

Commit 8360f57

Browse files
committed
MOBILE-4067 home: Display Dashboard if WS call fails
1 parent 0b1a395 commit 8360f57

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/core/features/courses/pages/my/my.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { CoreCoursesDashboard, CoreCoursesDashboardProvider } from '@features/co
2020
import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager';
2121
import { IonRefresher } from '@ionic/angular';
2222
import { CoreSites } from '@services/sites';
23+
import { CoreDomUtils } from '@services/utils/dom';
2324
import { CoreUtils } from '@services/utils/utils';
2425
import { CoreEventObserver, CoreEvents } from '@singletons/events';
2526
import { CoreCourses } from '../../services/courses';
@@ -90,7 +91,9 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
9091
await CoreUtils.nextTicks(2);
9192

9293
this.myOverviewBlock = this.block?.dynamicComponent?.instance as AddonBlockMyOverviewComponent;
93-
} catch {
94+
} catch (error) {
95+
CoreDomUtils.showErrorModal(error);
96+
9497
// Cannot get the blocks, just show the block if needed.
9598
this.loadFallbackBlock();
9699
}

src/core/features/courses/services/handlers/dashboard-home.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@feat
1818
import { CoreSites } from '@services/sites';
1919
import { CoreUtils } from '@services/utils/utils';
2020
import { makeSingleton } from '@singletons';
21+
import { CoreLogger } from '@singletons/logger';
2122
import { CoreCoursesDashboard } from '../dashboard';
2223

2324
/**
@@ -30,6 +31,11 @@ export class CoreDashboardHomeHandlerService implements CoreMainMenuHomeHandler
3031

3132
name = 'CoreCoursesDashboard';
3233
priority = 1200;
34+
logger: CoreLogger;
35+
36+
constructor() {
37+
this.logger = CoreLogger.getInstance('CoreDashboardHomeHandlerService');
38+
}
3339

3440
/**
3541
* Check if the handler is enabled on a site level.
@@ -59,9 +65,17 @@ export class CoreDashboardHomeHandlerService implements CoreMainMenuHomeHandler
5965
const dashboardEnabled = !dashboardDisabled && dashboardConfig !== '0';
6066

6167
if (dashboardAvailable && dashboardEnabled && !blocksDisabled) {
62-
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, siteId);
68+
try {
69+
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, siteId);
70+
71+
return CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks) ||
72+
CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);
73+
} catch (error) {
74+
// Error getting blocks, assume it's enabled.
75+
this.logger.error('Error getting Dashboard blocks', error);
6376

64-
return CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks) || CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);
77+
return true;
78+
}
6579
}
6680

6781
// Dashboard is enabled but not available, we will fake blocks.

0 commit comments

Comments
 (0)