Skip to content
Snippets Groups Projects
Commit 18b168b5 authored by Tom Käsler's avatar Tom Käsler
Browse files

Refactor comment userId attribute to creatorId

Add snackbar notification when a users comment got favorited
parent 321ec335
No related merge requests found
......@@ -56,7 +56,7 @@ export class CreateCommentComponent implements OnInit {
const comment = new Comment();
comment.roomId = localStorage.getItem(`roomId`);
comment.body = body;
comment.userId = this.user.id;
comment.creatorId = this.user.id;
comment.createdFromLecturer = this.user.role === 1;
this.dialogRef.close(comment);
}
......
......@@ -194,6 +194,12 @@ export class CommentListComponent implements OnInit {
break;
case this.favorite:
this.comments[i].favorite = <boolean>value;
console.log(this.comments[i]);
if (this.user.id === this.comments[i].creatorId && <boolean>value) {
this.translateService.get('comment-list.comment-got-favorited').subscribe( msg => {
this.notificationService.show(msg);
});
}
break;
case 'score':
this.comments[i].score = <number>value;
......
......@@ -3,7 +3,7 @@ import { CorrectWrong } from './correct-wrong.enum';
export class Comment {
id: string;
roomId: string;
userId: string;
creatorId: string;
revision: string;
body: string;
read: boolean;
......@@ -16,7 +16,7 @@ export class Comment {
ack: boolean;
constructor(roomId: string = '',
userId: string = '',
creatorId: string = '',
body: string = '',
read: boolean = false,
correct: CorrectWrong = CorrectWrong.NULL,
......@@ -28,7 +28,7 @@ export class Comment {
ack: boolean = true) {
this.id = '';
this.roomId = roomId;
this.userId = userId;
this.creatorId = creatorId;
this.revision = '';
this.body = body;
this.read = read;
......
......@@ -20,7 +20,7 @@ export class WsCommentServiceService {
constructor(private wsConnector: WsConnectorService) { }
add(comment: Comment): void {
const message = new CreateComment(comment.roomId, comment.userId, comment.body);
const message = new CreateComment(comment.roomId, comment.creatorId, comment.body);
this.wsConnector.send(`/queue/comment.command.create`, JSON.stringify(message));
}
......
......@@ -28,6 +28,7 @@
"add-comment": "Stell deine Frage!",
"pause-comments": "Pausiere den Fragen-Stream",
"play-comments": "Starte den Fragen-Stream",
"comment-got-favorited": "Eine Frage von dir wurde favorisiert!",
"comment-stream-stopped": "Der Fragen-Stream wurde gestoppt.",
"comment-stream-started": "Der Fragen-Stream wurde gestartet.",
"comment-sent": "Die Frage wurde veröffentlicht.",
......
......@@ -28,6 +28,7 @@
"add-comment": "Ask a question!",
"pause-comments": "Pause the question stream",
"play-comments": "Start the question stream",
"comment-got-favorited": "A question of yours got favorited!",
"comment-stream-stopped": "Question stream has been stopped.",
"comment-stream-started": "Question stream has been started.",
"comment-sent": "The question has been published.",
......
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