From a4c60925d99ab53b9a74cd1e32c14f3262db5614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 15 Dec 2021 12:30:35 +0100 Subject: [PATCH] MOBILE-3833 sitehome: Update userhomepage site info type --- src/core/classes/site.ts | 11 ++++++++++- .../sitehome/services/handlers/sitehome-home.ts | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 7b03c32bf..201b23ba1 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -2118,7 +2118,7 @@ export type CoreSiteInfoResponse = { usercanmanageownfiles?: boolean; // True if the user can manage his own files. userquota?: number; // User quota (bytes). 0 means user can ignore the quota. usermaxuploadfilesize?: number; // User max upload file size (bytes). -1 means the user can ignore the upload file size. - userhomepage?: number; // The default home page for the user: 0 for the site home, 1 for dashboard. + userhomepage?: CoreSiteInfoUserHomepage; // The default home page for the user. userprivateaccesskey?: string; // Private user access key for fetching files. siteid?: number; // Site course ID. sitecalendartype?: string; // Calendar type set in the site. @@ -2139,6 +2139,15 @@ export type CoreSiteInfo = CoreSiteInfoResponse & { }; }; +/** + * Enum constants that define default user home page. + */ +export enum CoreSiteInfoUserHomepage { + HOMEPAGE_SITE = 0, // Site home. + HOMEPAGE_MY = 1, // Dashboard. + HOMEPAGE_MYCOURSES = 3, // My courses. +}; + /** * Result of WS tool_mobile_get_config. */ diff --git a/src/core/features/sitehome/services/handlers/sitehome-home.ts b/src/core/features/sitehome/services/handlers/sitehome-home.ts index f5866cda7..dfae92fd4 100644 --- a/src/core/features/sitehome/services/handlers/sitehome-home.ts +++ b/src/core/features/sitehome/services/handlers/sitehome-home.ts @@ -17,6 +17,7 @@ import { CoreSites } from '@services/sites'; import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate'; import { CoreSiteHome } from '../sitehome'; import { makeSingleton } from '@singletons'; +import { CoreSiteInfoUserHomepage } from '@classes/site'; /** * Handler to add site home into home page. @@ -55,7 +56,8 @@ export class CoreSiteHomeHomeHandlerService implements CoreMainMenuHomeHandler { */ getDisplayData(): CoreMainMenuHomeHandlerToDisplay { const site = CoreSites.getCurrentSite(); - const displaySiteHome = site?.getInfo() && site?.getInfo()?.userhomepage === 0; + + const displaySiteHome = site?.getInfo() && site?.getInfo()?.userhomepage === CoreSiteInfoUserHomepage.HOMEPAGE_SITE; return { title: 'core.sitehome.sitehome',