Skip to content
Snippets Groups Projects
Commit 096a2ede authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Stop filter and sort comments permanently

parent 670e112b
No related merge requests found
......@@ -44,19 +44,19 @@
<mat-menu #filterMenu="matMenu" xPosition="before">
<div>
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filter(correct)">
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filterComments(correct)">
<mat-icon [ngClass]="{correct: 'correct-icon'}[currentFilter]">check_circle</mat-icon>
</button>
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filter(favorite)">
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filterComments(favorite)">
<mat-icon [ngClass]="{favorite: 'favorite-icon'}[currentFilter]">favorite</mat-icon>
</button>
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filter(read)">
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filterComments(read)">
<mat-icon [ngClass]="{read: 'read-icon'}[currentFilter]">visibility</mat-icon>
</button>
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filter(unread)">
<button mat-icon-button (focus)="hideCommentsList=true" (click)="filterComments(unread)">
<mat-icon [ngClass]="{unread: 'unread-icon'}[currentFilter]">visibility_off</mat-icon>
</button>
......@@ -67,7 +67,7 @@
</mat-menu>
</div>
<app-comment *ngFor="let current of showComments()" [comment]="current" [parseVote]="getVote(current)"></app-comment>
<app-comment *ngFor="let current of hideCommentsList ? filteredComments : comments" [comment]="current" [parseVote]="getVote(current)"></app-comment>
<div *ngIf="comments.length < 1" fxLayout="row" fxLayoutAlign="center center" class="no-comments">
<h4>{{ 'comment-page.no-comments' | translate }}</h4>
......
......@@ -70,6 +70,7 @@ export class CommentListComponent implements OnInit {
this.translateService.use(localStorage.getItem('currentLang'));
this.userRole = this.authenticationService.getRole();
this.deviceType = localStorage.getItem('deviceType');
this.getComments();
}
searchComments(term: string): void {
......@@ -81,23 +82,16 @@ export class CommentListComponent implements OnInit {
}
}
showComments(): Comment[] {
getComments(): void {
this.isLoading = false;
let commentThreshold = -10;
if (this.room.extensions && this.room.extensions['comments']) {
commentThreshold = this.room.extensions['comments'].commentThreshold;
if (this.hideCommentsList) {
return this.filteredComments.filter( x => x.score >= commentThreshold );
this.filteredComments = this.filteredComments.filter( x => x.score >= commentThreshold );
} else {
this.sort(this.currentSort);
return this.comments.filter( x => x.score >= commentThreshold );
}
} else {
if (this.hideCommentsList) {
return this.filteredComments;
} else {
this.sort(this.currentSort);
return this.comments;
this.comments = this.comments.filter( x => x.score >= commentThreshold );
}
}
}
......@@ -157,7 +151,8 @@ export class CommentListComponent implements OnInit {
}
break;
}
this.filter(this.currentFilter);
this.filterComments(this.currentFilter);
this.sort(this.currentSort);
}
openCreateDialog(): void {
......@@ -196,7 +191,7 @@ export class CommentListComponent implements OnInit {
this.filteredComments = this.comments.filter(c => c.correct);
}
filter(type: string): void {
filterComments(type: string): void {
this.currentFilter = type;
switch (type) {
case this.correct:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment