diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index a471c154e369d3bd56d88fc77dab6c7caa490a1d..c675aabe36bd77e15998dd2b5cc4feba85df09ad 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -44,6 +44,9 @@ export class CommentComponent implements OnInit, AfterViewInit { @Output() clickedOnTag = new EventEmitter<string>(); @Output() clickedOnKeyword = new EventEmitter<string>(); @Output() clickedUserNumber = new EventEmitter<number>(); + @ViewChild('commentBody', { static: true })commentBody: RowComponent; + @ViewChild('commentBodyInner', { static: true })commentBodyInner: RowComponent; + @ViewChild('commentExpander', { static: true })commentExpander: RowComponent; isStudent = false; isCreator = false; isModerator = false; @@ -54,12 +57,10 @@ export class CommentComponent implements OnInit, AfterViewInit { currentVote: string; slideAnimationState = 'hidden'; roleString: string; - @ViewChild('commentBody', { static: true })commentBody: RowComponent; - @ViewChild('commentBodyInner', { static: true })commentBodyInner: RowComponent; - @ViewChild('commentExpander', { static: true })commentExpander: RowComponent; isExpanded = false; isExpandable = false; - selectedKeyword: string = ''; + selectedKeyword = ''; + filterProfanityForModerators = false; constructor(protected authenticationService: AuthenticationService, private route: ActivatedRoute, @@ -104,6 +105,19 @@ export class CommentComponent implements OnInit, AfterViewInit { } } + changeProfanityShowForModerators(comment: Comment) { + let newBody: string; + if (this.filterProfanityForModerators) { + newBody = this.roomDataService.getFilteredBody(comment.id); + } else { + newBody = this.roomDataService.getUnFilteredBody(comment.id); + } + if (newBody) { + comment.body = newBody; + } + this.filterProfanityForModerators = !this.filterProfanityForModerators; + } + ngAfterViewInit(): void { this.isExpandable = this.commentBody.getRenderedHeight() > CommentComponent.COMMENT_MAX_HEIGHT; if (!this.isExpandable) { diff --git a/src/app/services/util/room-data.service.ts b/src/app/services/util/room-data.service.ts index 498e8c262c4ed96183595d7107d29987cf827212..5e0a3b4624b71403631529003f575fea42181f96 100644 --- a/src/app/services/util/room-data.service.ts +++ b/src/app/services/util/room-data.service.ts @@ -157,6 +157,14 @@ export class RoomDataService { } } + getUnFilteredBody(id: string): string { + return this._savedCommentsBeforeFilter.get(id); + } + + getFilteredBody(id: string): string { + return this._savedCommentsAfterFilter.get(id); + } + private setCommentBody(comment: Comment) { this._savedCommentsBeforeFilter.set(comment.id, comment.body); this._savedCommentsAfterFilter.set(comment.id, this.filterCommentOfProfanity(this.room, comment));