aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/post-page
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-03-14 08:41:52 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-03-14 08:41:52 +0200
commit065bfead76fc9e94c8344d812ee7f5b214c74321 (patch)
tree997d75eec34baf7bedc09932851425ff0bfac752 /src/app/components/post-page
parent82594c050a9bbd1f527142ffe21e66c8c5f27ba3 (diff)
downloadDevHive-Angular-065bfead76fc9e94c8344d812ee7f5b214c74321.tar
DevHive-Angular-065bfead76fc9e94c8344d812ee7f5b214c74321.tar.gz
DevHive-Angular-065bfead76fc9e94c8344d812ee7f5b214c74321.zip
Update post and post-page's subscriptions to use an observer object
Diffstat (limited to 'src/app/components/post-page')
-rw-r--r--src/app/components/post-page/post-page.component.ts32
1 files changed, 16 insertions, 16 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 {