From a21b582b9367c2043f040aab2989ff4705adbf2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Sat, 8 Jun 2019 17:54:32 +0200 Subject: [PATCH] Stop checking votes as creator --- .../comment-list/comment-list.component.ts | 16 ++++++++++------ .../shared/comment/comment.component.ts | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 5c2015db9..fc6f5f3e5 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -57,11 +57,6 @@ export class CommentListComponent implements OnInit { ngOnInit() { this.roomId = localStorage.getItem(`roomId`); const userId = this.authenticationService.getUser().id; - this.voteService.getByRoomIdAndUserID(this.roomId, userId).subscribe(votes => { - for (const v of votes) { - this.commentVoteMap.set(v.commentId, v); - } - }); this.roomService.getRoom(this.roomId).subscribe( room => this.room = room); this.hideCommentsList = false; this.wsCommentService.getCommentStream(this.roomId).subscribe((message: Message) => { @@ -70,6 +65,13 @@ export class CommentListComponent implements OnInit { this.translateService.use(localStorage.getItem('currentLang')); this.userRole = this.authenticationService.getRole(); this.deviceType = localStorage.getItem('deviceType'); + if (this.userRole === 0) { + this.voteService.getByRoomIdAndUserID(this.roomId, userId).subscribe(votes => { + for (const v of votes) { + this.commentVoteMap.set(v.commentId, v); + } + }); + } this.getComments(); } @@ -97,7 +99,9 @@ export class CommentListComponent implements OnInit { } getVote(comment: Comment): Vote { - return this.commentVoteMap.get(comment.id); + if (this.userRole === 0) { + return this.commentVoteMap.get(comment.id); + } } parseIncomingMessage(message: Message) { diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index 959006531..d7f60c701 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -77,7 +77,9 @@ export class CommentComponent implements OnInit { @Input() set parseVote(vote: Vote) { - this.hasVoted = vote.vote; + if (this.isStudent) { + this.hasVoted = vote.vote; + } } resetAnimationState(): void { -- GitLab