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 91d4a6d78737b2b509d9b10b79beded5cb8b4e0b..379d71db5044976948c8687e76e890a970c85c84 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -58,7 +58,24 @@ export class CommentListComponent implements OnInit { c.id = payload.id; c.creationTimestamp = payload.timestamp; this.comments = this.comments.concat(c); + } else if (msg.type === 'CommentPatched') { + for (let i = 0; i < this.comments.length; i++) { + if (payload.id === this.comments[i].id) { + for (const [key, value] of Object.entries(payload.changes)) { + console.log(value); + switch (key) { + case 'read': this.comments[i].read = value; + break; + case 'correct' : this.comments[i].correct = value; + break; + case 'favorite' : this.comments[i].favorite = value; + break; + } + } + } + } } } + } diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index fb64a3436aa497b05756c358c12bfa73abad9d31..35776dec460568f0032452bdbc007b60feba8f6e 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -8,8 +8,6 @@ import { NotificationService } from '../../../services/util/notification.service import { TranslateService } from '@ngx-translate/core'; import { LanguageService } from '../../../services/util/language.service'; import { WsCommentServiceService } from '../../../services/websockets/ws-comment-service.service'; -import { RxStompService } from '@stomp/ng2-stompjs'; -import { Message } from '@stomp/stompjs'; @Component({ selector: 'app-comment', @@ -28,8 +26,7 @@ export class CommentComponent implements OnInit { private notification: NotificationService, private translateService: TranslateService, protected langService: LanguageService, - private wsCommentService: WsCommentServiceService, - private rxStompService: RxStompService) { + private wsCommentService: WsCommentServiceService) { langService.langEmitter.subscribe(lang => translateService.use(lang)); } ngOnInit() { @@ -37,9 +34,6 @@ export class CommentComponent implements OnInit { this.isCreator = true; } this.translateService.use(localStorage.getItem('currentLang')); - this.rxStompService.watch(`/topic/${this.comment.roomId}.comment.stream`).subscribe((message: Message) => { - this.parseIncomingMessage(message); - }); } setRead(comment: Comment): void { @@ -62,7 +56,7 @@ export class CommentComponent implements OnInit { this.notification.show(`Comment '${comment.body}' successfully deleted.`); }); } - + /* parseIncomingMessage(message: Message) { const msg = JSON.parse(message.body); const payload = msg.payload; @@ -78,5 +72,5 @@ export class CommentComponent implements OnInit { } } } - } + } */ }