From d5e80804e0124fe1f82fb7b107e7da9e49f4fe24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Thu, 7 Mar 2019 13:18:46 +0100
Subject: [PATCH] Fix current-content-group bug

---
 .../statistics-page/statistics-page.component.ts    | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/app/components/shared/statistics-page/statistics-page.component.ts b/src/app/components/shared/statistics-page/statistics-page.component.ts
index c51805115..07eb8be76 100644
--- a/src/app/components/shared/statistics-page/statistics-page.component.ts
+++ b/src/app/components/shared/statistics-page/statistics-page.component.ts
@@ -34,7 +34,10 @@ export class StatisticsPageComponent implements OnInit {
   }
 
   ngOnInit(): void {
-    this.currentCG = sessionStorage.getItem('contentGroup');
+    if (sessionStorage.getItem('contentGroup')) {
+      console.log('in if');
+      this.currentCG = sessionStorage.getItem('contentGroup');
+    }
     this.getRoom(localStorage.getItem('roomId'));
     this.tabGroup.selectedIndex = 1;
   }
@@ -44,9 +47,11 @@ export class StatisticsPageComponent implements OnInit {
     this.roomService.getRoom(id).subscribe(room => {
       this.contentGroups = room.contentGroups;
       if (this.contentGroups) {
-        for (let i = 0; i < this.contentGroups.length; i++) {
-          if (this.currentCG.includes(this.contentGroups[i].name)) {
-            this.tabGroup.selectedIndex = i;
+        if( this.currentCG) {
+          for (let i = 0; i < this.contentGroups.length; i++) {
+            if (this.currentCG.includes(this.contentGroups[i].name)) {
+              this.tabGroup.selectedIndex = i;
+            }
           }
         }
       } else {
-- 
GitLab