Commit 1fecc23d authored by Lukas Mauß's avatar Lukas Mauß

Implement comment-stream-freeze functionality

parent a40f78ef
......@@ -36,13 +36,13 @@
</button>
<button id="pause-comments" mat-fab aria-labelledby="pause" class="actionButton"
*ngIf="!searchBox.value && !search && !freeze" (click)="freeze = true;"
*ngIf="!searchBox.value && !search && !freeze" (click)="pauseCommentStream()"
matTooltip="{{ 'comment-list.pause-comments' | translate }}">
<mat-icon class="pauseIcon">pause_circle_filled</mat-icon>
</button>
<button id="play-comments" mat-fab aria-labelledby="play" class="actionButton"
*ngIf="!searchBox.value && !search && freeze" (click)="freeze = false;"
*ngIf="!searchBox.value && !search && freeze" (click)="playCommentStream()"
matTooltip="{{ 'comment-list.play-comments' | translate }}">
<mat-icon class="playIcon">play_circle_filled</mat-icon>
</button>
......
......@@ -17,6 +17,7 @@ import { NotificationService } from '../../../services/util/notification.service
import { CorrectWrong } from '../../../models/correct-wrong.enum';
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { EventService } from '../../../services/util/event.service';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-comment-list',
......@@ -54,6 +55,8 @@ export class CommentListComponent implements OnInit {
moderationEnabled = false;
thresholdEnabled = false;
newestComment: string;
freeze = false;
commentStream: Subscription;
constructor(private commentService: CommentService,
private translateService: TranslateService,
......@@ -88,9 +91,7 @@ export class CommentListComponent implements OnInit {
});
});
this.hideCommentsList = false;
this.wsCommentService.getCommentStream(this.roomId).subscribe((message: Message) => {
this.parseIncomingMessage(message);
});
this.subscribeCommentStream();
this.translateService.use(localStorage.getItem('currentLang'));
this.deviceType = localStorage.getItem('deviceType');
if (this.userRole === 0) {
......@@ -311,6 +312,26 @@ export class CommentListComponent implements OnInit {
this.currentSort = type;
}
pauseCommentStream() {
this.freeze = true;
this.commentStream.unsubscribe();
}
playCommentStream() {
this.freeze = false;
this.commentService.getAckComments(this.roomId)
.subscribe(comments => {
this.comments = comments;
this.getComments();
});
this.subscribeCommentStream();
}
subscribeCommentStream() {
this.commentStream = this.wsCommentService.getCommentStream(this.roomId).subscribe((message: Message) => {
this.parseIncomingMessage(message);
});
}
/**
* Announces a new comment receive.
......
Markdown is supported
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