From bf9648c2f4a5a6afa0bf165a3d5aa45a3ff3e28e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Fri, 16 Mar 2018 13:18:44 +0100
Subject: [PATCH] Fix loading spinner in comment-list

---
 src/app/comment-list/comment-list.component.ts | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/app/comment-list/comment-list.component.ts b/src/app/comment-list/comment-list.component.ts
index b942f1037..0a015a2b0 100644
--- a/src/app/comment-list/comment-list.component.ts
+++ b/src/app/comment-list/comment-list.component.ts
@@ -27,7 +27,8 @@ export class CommentListComponent implements OnInit {
     private roomService: RoomService,
     private location: Location,
     private commentService: CommentService,
-    private notification: NotificationService) { }
+    private notification: NotificationService) {
+  }
 
   ngOnInit() {
     this.userRole = this.authenticationService.getRole();
@@ -47,16 +48,21 @@ export class CommentListComponent implements OnInit {
   getComments(roomId: string): void {
     if (this.userRole === UserRole.CREATOR) {
       this.commentService.getComments(roomId)
-        .subscribe(comments => this.comments = comments);
+        .subscribe(comments => {
+          this.comments = comments;
+          this.isLoading = false;
+        });
     } else if (this.userRole === UserRole.PARTICIPANT) {
       this.commentService.searchComments(roomId, this.user.id)
-        .subscribe(comments => this.comments = comments);
+        .subscribe(comments => {
+          this.comments = comments;
+          this.isLoading = false;
+        });
     }
-    this.isLoading = false;
   }
 
   setRead(comment: Comment): void {
-    this.comments.find( c => c.id === comment.id).read = !comment.read;
+    this.comments.find(c => c.id === comment.id).read = !comment.read;
     this.commentService.updateComment(comment).subscribe();
   }
 
-- 
GitLab