diff options
| author | Kamen Mladenov <kamen.d.mladenov@protonmail.com> | 2021-03-14 09:11:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-14 09:11:46 +0200 |
| commit | d2d4452bfa4861458bc0ba6a618c2a27decc8051 (patch) | |
| tree | 4cb5a0352865cbab3c5ae93141be9b7b2dae53df /src/app/components/comment-page/comment-page.component.ts | |
| parent | d8ffe52b67e983b9b317b2e5dcb138ac996eaa31 (diff) | |
| parent | e3a8875e64c25a6e46380c4d003beac5953fd3e9 (diff) | |
| download | DevHive-Angular-d2d4452bfa4861458bc0ba6a618c2a27decc8051.tar DevHive-Angular-d2d4452bfa4861458bc0ba6a618c2a27decc8051.tar.gz DevHive-Angular-d2d4452bfa4861458bc0ba6a618c2a27decc8051.zip | |
Merge pull request #1 from Team-Kaleidoscope/code-refactor
Code refactor
Diffstat (limited to 'src/app/components/comment-page/comment-page.component.ts')
| -rw-r--r-- | src/app/components/comment-page/comment-page.component.ts | 22 |
1 files changed, 11 insertions, 11 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..5d256bf 100644 --- a/src/app/components/comment-page/comment-page.component.ts +++ b/src/app/components/comment-page/comment-page.component.ts @@ -5,7 +5,7 @@ import { Router } from '@angular/router'; import { Guid } from 'guid-typescript'; import { CommentService } from 'src/app/services/comment.service'; import { TokenService } from 'src/app/services/token.service'; -import { Comment } from 'src/models/comment'; +import { Comment } from 'src/models/comment.model'; @Component({ selector: 'app-comment-page', @@ -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 { |
