diff options
| author | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-03-13 12:08:44 +0200 |
|---|---|---|
| committer | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-03-13 12:08:44 +0200 |
| commit | 341aafe72c96cad41bc5b8f1bdf665c4f2cd5319 (patch) | |
| tree | a2b5f384fc23ccc2db320ebf961c96e5393ce702 | |
| parent | 98d4f0e3a0fc8fd8d753617a2b681a18f8a60e2b (diff) | |
| download | DevHive-Angular-341aafe72c96cad41bc5b8f1bdf665c4f2cd5319.tar DevHive-Angular-341aafe72c96cad41bc5b8f1bdf665c4f2cd5319.tar.gz DevHive-Angular-341aafe72c96cad41bc5b8f1bdf665c4f2cd5319.zip | |
improved rating system
| -rw-r--r-- | .vs/slnx.sqlite | bin | 167936 -> 167936 bytes | |||
| -rw-r--r-- | src/app/components/post/post.component.html | 4 | ||||
| -rw-r--r-- | src/app/components/post/post.component.ts | 31 |
3 files changed, 7 insertions, 28 deletions
diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite Binary files differindex 2061481..6561dfb 100644 --- a/.vs/slnx.sqlite +++ b/.vs/slnx.sqlite diff --git a/src/app/components/post/post.component.html b/src/app/components/post/post.component.html index 830fa75..1603ebf 100644 --- a/src/app/components/post/post.component.html +++ b/src/app/components/post/post.component.html @@ -30,13 +30,13 @@ </div> </section> <section class="rating"> - <button class="vote" (click)="upVotePost()"> + <button class="vote" (click)="votePost(true)"> ᐃ </button> <summary class="score"> {{ votesNumber }} </summary> - <button class="vote" (click)="downVotePost()"> + <button class="vote" (click)="votePost(false)"> ᐁ </button> </section> 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); } ); } |
