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

Remove rejected comments of indexedDB

parent aeb88f9b
Branches
1 merge request!381WIP: Resolve "Have a better strategy for sharing data"
Pipeline #29990 failed with stages
in 1 minute and 21 seconds
...@@ -156,7 +156,6 @@ export class CommentListComponent implements OnInit { ...@@ -156,7 +156,6 @@ export class CommentListComponent implements OnInit {
c.id = payload.id; c.id = payload.id;
c.timestamp = payload.timestamp; c.timestamp = payload.timestamp;
this.addComment(c); this.addComment(c);
this.updateComments();
break; break;
case 'CommentPatched': case 'CommentPatched':
// ToDo: Use a map for comments w/ key = commentId // ToDo: Use a map for comments w/ key = commentId
...@@ -166,34 +165,36 @@ export class CommentListComponent implements OnInit { ...@@ -166,34 +165,36 @@ export class CommentListComponent implements OnInit {
switch (key) { switch (key) {
case this.read: case this.read:
this.comments[i].read = <boolean>value; this.comments[i].read = <boolean>value;
this.updateDatabase();
break; break;
case this.correct: case this.correct:
this.comments[i].correct = <boolean>value; this.comments[i].correct = <boolean>value;
this.updateDatabase();
break; break;
case this.favorite: case this.favorite:
this.comments[i].favorite = <boolean>value; this.comments[i].favorite = <boolean>value;
this.updateDatabase();
break; break;
case 'score': case 'score':
this.comments[i].score = <number>value; this.comments[i].score = <number>value;
this.updateDatabase();
break; break;
case this.ack: case this.ack:
const isNowAck = <boolean>value; const isNowAck = <boolean>value;
if (!isNowAck) { if (!isNowAck) {
this.comments = this.comments.filter(function (el) { this.deleteComment(payload.id);
return el.id !== payload.id;
});
} }
} }
} }
} }
} }
this.updateDatabase();
break; break;
case 'CommentHighlighted': case 'CommentHighlighted':
// ToDo: Use a map for comments w/ key = commentId // ToDo: Use a map for comments w/ key = commentId
for (let i = 0; i < this.comments.length; i++) { for (let i = 0; i < this.comments.length; i++) {
if (payload.id === this.comments[i].id) { if (payload.id === this.comments[i].id) {
this.comments[i].highlighted = <boolean>payload.lights; this.comments[i].highlighted = <boolean>payload.lights;
this.updateDatabase();
} }
} }
break; break;
...@@ -227,10 +228,12 @@ export class CommentListComponent implements OnInit { ...@@ -227,10 +228,12 @@ export class CommentListComponent implements OnInit {
addComment(comment: Comment): void { addComment(comment: Comment): void {
this.databaseService.comments.add(comment); this.databaseService.comments.add(comment);
this.updateComments();
} }
deleteComment(id: string) { deleteComment(id: string) {
this.databaseService.comments.delete(id); this.databaseService.comments.delete(id);
this.updateComments();
} }
async updateComments() { async updateComments() {
......
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