diff options
Diffstat (limited to 'src/app/components/post/post.component.ts')
| -rw-r--r-- | src/app/components/post/post.component.ts | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts index 1ec9232..0be3c43 100644 --- a/src/app/components/post/post.component.ts +++ b/src/app/components/post/post.component.ts @@ -59,7 +59,7 @@ export class PostComponent implements OnInit { this._router.navigate(['/post/' + this.post.postId]); } - upVotePost(): void { + votePost(isLike: boolean): void { if (!this.loggedIn) { this._router.navigate(['/login']); return; @@ -67,36 +67,15 @@ export class PostComponent implements OnInit { this._ratingServe.getRatingByUserAndPostWithSessionStorageRequest(Guid.parse(this.paramId)).subscribe( (x: object) => { - if (Object.values(x)[3]) { - this.deleteRating(Object.values(x)[0], true); + if (Object.values(x)[3] === isLike) { + this.deleteRating(Object.values(x)[0], isLike); } else { - this.putRating(true); + this.putRating(isLike); } }, () => { - this.crateRating(true); - } - ); - } - - downVotePost(): void { - if (!this.loggedIn) { - this._router.navigate(['/login']); - return; - } - - this._ratingServe.getRatingByUserAndPostWithSessionStorageRequest(Guid.parse(this.paramId)).subscribe( - (x: object) => { - if (!Object.values(x)[3]) { - this.deleteRating(Object.values(x)[0], false); - } - else { - this.putRating(false); - } - }, - () => { - this.crateRating(false); + this.crateRating(isLike); } ); } |
