From f06e25d1cde480efc36c71dc50b8a610b2bf0c7e Mon Sep 17 00:00:00 2001
From: Albert Gasset <albertgasset@fsfe.org>
Date: Fri, 24 May 2019 12:48:44 +0200
Subject: [PATCH] MOBILE-3049 sitehome: Fix activities not displayed

---
 .../sitemainmenu/components/sitemainmenu/sitemainmenu.ts     | 2 +-
 src/core/sitehome/components/index/index.ts                  | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts b/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts
index 02c044771..0f3355219 100644
--- a/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts
+++ b/src/addon/block/sitemainmenu/components/sitemainmenu/sitemainmenu.ts
@@ -75,7 +75,7 @@ export class AddonBlockSiteMainMenuComponent extends CoreBlockBaseComponent impl
      */
     protected fetchContent(): Promise<any> {
         return this.courseProvider.getSections(this.siteHomeId, false, true).then((sections) => {
-            this.block = sections[0];
+            this.block = sections.find((section) => section.section == 0);
 
             if (this.block) {
                 this.block.hasContent = this.courseHelper.sectionHasContent(this.block);
diff --git a/src/core/sitehome/components/index/index.ts b/src/core/sitehome/components/index/index.ts
index 354881d3b..c21f2b1d9 100644
--- a/src/core/sitehome/components/index/index.ts
+++ b/src/core/sitehome/components/index/index.ts
@@ -137,7 +137,7 @@ export class CoreSiteHomeIndexComponent implements OnInit {
         return this.courseProvider.getSections(this.siteHomeId, false, true).then((sections) => {
 
             // Check "Include a topic section" setting from numsections.
-            this.section = config.numsections ? sections[1] : false;
+            this.section = config.numsections ? sections.find((section) => section.section == 1) : false;
             if (this.section) {
                 this.section.hasContent = this.courseHelper.sectionHasContent(this.section);
                 this.hasContent = this.courseHelper.addHandlerDataForModules([this.section], this.siteHomeId) || this.hasContent;
@@ -164,7 +164,8 @@ export class CoreSiteHomeIndexComponent implements OnInit {
                 this.blocks = [];
 
                 // Cannot get the blocks, just show site main menu if needed.
-                if (sections[0] && this.courseHelper.sectionHasContent(sections[0])) {
+                const section = sections.find((section) => section.section == 0);
+                if (section && this.courseHelper.sectionHasContent(section)) {
                     this.blocks.push({
                         name: 'site_main_menu'
                     });