diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-14 08:34:59 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-14 08:34:59 +0200 |
| commit | 807e72b990e7412bdf243095a07bd716bb93453f (patch) | |
| tree | 3d89861fb5bab4fcf11872a2b262bb192948a32a /src/app/components/comment-page | |
| parent | 94d421d08f24b117b58bc87799861016fbff8ec0 (diff) | |
| download | DevHive-Angular-807e72b990e7412bdf243095a07bd716bb93453f.tar DevHive-Angular-807e72b990e7412bdf243095a07bd716bb93453f.tar.gz DevHive-Angular-807e72b990e7412bdf243095a07bd716bb93453f.zip | |
Updated comment and comment-page's subscriptions to use an observer object
Diffstat (limited to 'src/app/components/comment-page')
| -rw-r--r-- | src/app/components/comment-page/comment-page.component.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/app/components/comment-page/comment-page.component.ts b/src/app/components/comment-page/comment-page.component.ts index 413436e..9bbdc59 100644 --- a/src/app/components/comment-page/comment-page.component.ts +++ b/src/app/components/comment-page/comment-page.component.ts @@ -32,8 +32,8 @@ export class CommentPageComponent implements OnInit { // Gets the post and the logged in user and compares them, // to determine if the current post is made by the user - this._commentService.getCommentRequest(this.commentId).subscribe( - (result: object) => { + this._commentService.getCommentRequest(this.commentId).subscribe({ + next: (result: object) => { this.comment = result as Comment; if (this.loggedIn) { this.editable = this.comment.issuerUsername === this._tokenService.getUsernameFromSessionStorageToken(); @@ -41,10 +41,10 @@ export class CommentPageComponent implements OnInit { } this.loaded = true; }, - () => { + error: () => { this._router.navigate(['/not-found']); } - ); + }); this.editCommentFormGroup = this._fb.group({ newCommentMessage: new FormControl('') @@ -66,22 +66,22 @@ export class CommentPageComponent implements OnInit { if (newMessage !== '' && newMessage !== this.comment.message) { console.log(this.commentId); - this._commentService.putCommentWithSessionStorageRequest(this.commentId, this.comment.postId, newMessage).subscribe( - () => { + this._commentService.putCommentWithSessionStorageRequest(this.commentId, this.comment.postId, newMessage).subscribe({ + next: () => { this.reloadPage(); } - ); + }); } } this.editingComment = !this.editingComment; } deleteComment(): void { - this._commentService.deleteCommentWithSessionStorage(this.commentId).subscribe( - () => { + this._commentService.deleteCommentWithSessionStorage(this.commentId).subscribe({ + next: () => { this.toPost(); } - ); + }); } private reloadPage(): void { |
