aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/post
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-04-08 09:53:43 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-04-08 09:53:43 +0300
commitdb07f57d50e6a9b304886816e23643747d7bfac8 (patch)
treef2a2a9a132b88156c7c3bc8e6c923dc2ddbd3a1a /src/app/components/post
parent601b39df7da18bfa80a0443be258ccee74403b0a (diff)
downloadDevHive-Angular-db07f57d50e6a9b304886816e23643747d7bfac8.tar
DevHive-Angular-db07f57d50e6a9b304886816e23643747d7bfac8.tar.gz
DevHive-Angular-db07f57d50e6a9b304886816e23643747d7bfac8.zip
Fixed liking functionality (after change in api)
Diffstat (limited to 'src/app/components/post')
-rw-r--r--src/app/components/post/post.component.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts
index c05bd10..e8ba430 100644
--- a/src/app/components/post/post.component.ts
+++ b/src/app/components/post/post.component.ts
@@ -176,7 +176,12 @@ export class PostComponent implements OnInit, AfterViewInit {
this._ratingServe.getRatingByUserAndPostWithSessionStorageRequest(Guid.parse(this.paramId)).subscribe({
next: (x: object) => {
- if (Object.values(x)[3] === isLike) {
+ if (x == null) { // checks if result is null or undefined
+ this.createRating(isLike);
+
+ this.changeColorOfVoteButton(isLike, !isLike);
+ }
+ else if (Object.values(x)[3] === isLike) {
this.deleteRating(Object.values(x)[0], isLike);
this.changeColorOfVoteButton(false, false);
@@ -186,11 +191,6 @@ export class PostComponent implements OnInit, AfterViewInit {
this.changeColorOfVoteButton(isLike, !isLike);
}
- },
- error: () => {
- this.createRating(isLike);
-
- this.changeColorOfVoteButton(isLike, !isLike);
}
});
}