aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vs/slnx.sqlitebin167936 -> 167936 bytes
-rw-r--r--src/app/components/post/post.component.ts13
2 files changed, 8 insertions, 5 deletions
diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite
index c62291d..6863014 100644
--- a/.vs/slnx.sqlite
+++ b/.vs/slnx.sqlite
Binary files differ
diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts
index b2742c0..bf43a83 100644
--- a/src/app/components/post/post.component.ts
+++ b/src/app/components/post/post.component.ts
@@ -73,20 +73,18 @@ export class PostComponent implements OnInit {
if (Object.values(x)[3] === isLike) {
this.deleteRating(Object.values(x)[0], isLike);
- this.voteBtns.item(Number(!isLike))!.style.backgroundColor = 'white';
- this.voteBtns.item(Number(isLike))!.style.backgroundColor = 'white';
+ this.changeColorOfVoteButton(false, false);
}
else {
this.putRating(isLike);
- this.voteBtns.item(Number(!isLike))!.style.backgroundColor = 'lightblue';
- this.voteBtns.item(Number(isLike))!.style.backgroundColor = 'white';
+ this.changeColorOfVoteButton(isLike, !isLike);
}
},
() => {
this.createRating(isLike);
- this.voteBtns.item(Number(!isLike))!.style.backgroundColor = 'lightblue';
+ this.changeColorOfVoteButton(isLike, !isLike);
}
);
}
@@ -115,4 +113,9 @@ export class PostComponent implements OnInit {
}
);
}
+
+ private changeColorOfVoteButton(isUpvoted: boolean, isDownvoted: boolean): void {
+ this.voteBtns.item(0)!.style.backgroundColor = (isUpvoted) ? 'lightblue' : 'white';
+ this.voteBtns.item(1)!.style.backgroundColor = (isDownvoted) ? 'lightblue' : 'white';
+ }
}