diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-04-08 09:53:43 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-04-08 09:53:43 +0300 |
| commit | db07f57d50e6a9b304886816e23643747d7bfac8 (patch) | |
| tree | f2a2a9a132b88156c7c3bc8e6c923dc2ddbd3a1a /src/app/components/post/post.component.ts | |
| parent | 601b39df7da18bfa80a0443be258ccee74403b0a (diff) | |
| download | DevHive-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/post.component.ts')
| -rw-r--r-- | src/app/components/post/post.component.ts | 12 |
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); } }); } |
