aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-14 20:03:39 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-14 20:03:39 +0200
commit07c30c0896de316119b188c9e62f4666bf0cb2a9 (patch)
tree7201765a9ca7c24ad2a029c68c25c265185cecb9
parent8419a8e403abf5b25e3b53655cfafabf4eb30a3e (diff)
downloadDevHive-Angular-07c30c0896de316119b188c9e62f4666bf0cb2a9.tar
DevHive-Angular-07c30c0896de316119b188c9e62f4666bf0cb2a9.tar.gz
DevHive-Angular-07c30c0896de316119b188c9e62f4666bf0cb2a9.zip
added functionality to highlight buttons on init
-rw-r--r--.vs/DevHive-Angular/v16/.suobin62976 -> 65024 bytes
-rw-r--r--.vs/slnx.sqlitebin167936 -> 167936 bytes
-rw-r--r--src/app/components/post/post.component.ts24
3 files changed, 22 insertions, 2 deletions
diff --git a/.vs/DevHive-Angular/v16/.suo b/.vs/DevHive-Angular/v16/.suo
index 7c63106..60e79b7 100644
--- a/.vs/DevHive-Angular/v16/.suo
+++ b/.vs/DevHive-Angular/v16/.suo
Binary files differ
diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite
index 6863014..8f7e0c6 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 bf43a83..572ad9c 100644
--- a/src/app/components/post/post.component.ts
+++ b/src/app/components/post/post.component.ts
@@ -34,15 +34,23 @@ export class PostComponent implements OnInit {
this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe(
(result: object) => {
Object.assign(this.post, result);
+
+ console.log(this.post.postId);
+
this.post.fileURLs = Object.values(result)[7];
this.votesNumber = this.post.currentRating;
this.voteBtns = document.getElementsByClassName('vote') as HTMLCollectionOf<HTMLElement>;
- this.timeCreated = new Date(this.post.timeCreated).toLocaleString('en-GB');
+ this.timeCreated = new Date(this.post.timeCreated).toLocaleString('en-GB');
+
this.loadUser();
}
);
+
+ window.addEventListener("load", () => {
+ this.highlightButtonsOnInit();
+ });
}
private loadUser(): void {
@@ -107,7 +115,7 @@ export class PostComponent implements OnInit {
}
private deleteRating(ratingId: string, isLike: boolean): void {
- this._ratingServe.deleteRatingFromSessionStorageRequest(Guid.parse(ratingId)).subscribe(
+ this._ratingServe.deleteRatingFromSessionStorageRequest(Guid.parse(this.paramId)).subscribe(
() => {
this.votesNumber += 1 - Number(isLike) * 2;
}
@@ -118,4 +126,16 @@ export class PostComponent implements OnInit {
this.voteBtns.item(0)!.style.backgroundColor = (isUpvoted) ? 'lightblue' : 'white';
this.voteBtns.item(1)!.style.backgroundColor = (isDownvoted) ? 'lightblue' : 'white';
}
+
+ private highlightButtonsOnInit(): void {
+ this._ratingServe.getRatingByUserAndPostWithSessionStorageRequest(Guid.parse(this.paramId)).subscribe(
+ (x: object) => {
+ const isLike: boolean = Object.values(x)[3];
+
+ console.log(this.voteBtns);
+
+ this.changeColorOfVoteButton(isLike, !isLike);
+ }
+ );
+ }
}