diff options
Diffstat (limited to 'src/app/components')
| -rw-r--r-- | src/app/components/post-page/post-page.component.ts | 32 | ||||
| -rw-r--r-- | src/app/components/post/post.component.ts | 12 |
2 files changed, 22 insertions, 22 deletions
diff --git a/src/app/components/post-page/post-page.component.ts b/src/app/components/post-page/post-page.component.ts index 1ac89f4..7c32ce0 100644 --- a/src/app/components/post-page/post-page.component.ts +++ b/src/app/components/post-page/post-page.component.ts @@ -37,8 +37,8 @@ export class PostPageComponent 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._postService.getPostRequest(this.postId).subscribe( - (result: object) => { + this._postService.getPostRequest(this.postId).subscribe({ + next: (result: object) => { this.post = result as Post; this.post.fileURLs = Object.values(result)[7]; if (this.loggedIn) { @@ -52,10 +52,10 @@ export class PostPageComponent implements OnInit { this.dataArrived = true; } }, - () => { + error: () => { this._router.navigate(['/not-found']); } - ); + }); this.editPostFormGroup = this._fb.group({ newPostMessage: new FormControl(''), @@ -69,8 +69,8 @@ export class PostPageComponent implements OnInit { private loadFiles(): void { for (const fileURL of this.post.fileURLs) { - this._cloudinaryService.getFileRequest(fileURL).subscribe( - (result: object) => { + this._cloudinaryService.getFileRequest(fileURL).subscribe({ + next: (result: object) => { const file = result as File; const tmp = { name: fileURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment' @@ -83,7 +83,7 @@ export class PostPageComponent implements OnInit { this.dataArrived = true; } } - ); + }); } } @@ -118,11 +118,11 @@ export class PostPageComponent implements OnInit { const newMessage = this.editPostFormGroup.get('newPostMessage')?.value; if (newMessage === '' && newMessage !== this.post.message) { - this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe( - () => { + this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe({ + next: () => { this.reloadPage(); } - ); + }); this.dataArrived = false; } } @@ -137,21 +137,21 @@ export class PostPageComponent implements OnInit { const newComment = this.addCommentFormGroup.get('newComment')?.value; if (newComment !== '' && newComment !== null) { - this._commentService.createCommentWithSessionStorageRequest(this.postId, newComment).subscribe( - () => { + this._commentService.createCommentWithSessionStorageRequest(this.postId, newComment).subscribe({ + next: () => { this.editPostFormGroup.reset(); this.reloadPage(); } - ); + }); } } deletePost(): void { - this._postService.deletePostWithSessionStorage(this.postId).subscribe( - () => { + this._postService.deletePostWithSessionStorage(this.postId).subscribe({ + next: () => { this._router.navigate(['/profile/' + this._tokenService.getUsernameFromSessionStorageToken()]); } - ); + }); } private reloadPage(): void { diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts index 387f56f..a46811d 100644 --- a/src/app/components/post/post.component.ts +++ b/src/app/components/post/post.component.ts @@ -26,8 +26,8 @@ export class PostComponent implements OnInit { this.post = this._postService.getDefaultPost(); this.user = this._userService.getDefaultUser(); - this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe( - (result: object) => { + this._postService.getPostRequest(Guid.parse(this.paramId)).subscribe({ + next: (result: object) => { Object.assign(this.post, result); this.post.fileURLs = Object.values(result)[7]; this.votesNumber = 23; @@ -35,16 +35,16 @@ export class PostComponent implements OnInit { this.timeCreated = new Date(this.post.timeCreated).toLocaleString('en-GB'); this.loadUser(); } - ); + }); } private loadUser(): void { - this._userService.getUserByUsernameRequest(this.post.creatorUsername).subscribe( - (result: object) => { + this._userService.getUserByUsernameRequest(this.post.creatorUsername).subscribe({ + next: (result: object) => { Object.assign(this.user, result); this.loaded = true; } - ); + }); } goToAuthorProfile(): void { |
