aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/post-page/post-page.component.ts
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-14 21:47:33 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-14 21:47:33 +0200
commite4fc300d2fe82084c67c50258c76b60248850863 (patch)
tree2b836291af4bc6801d7d809c828eb3e7d58a027a /src/app/components/post-page/post-page.component.ts
parentafe30ab78432d16c42b2f19e3bd8355e3f27a0e1 (diff)
parent988c09b9233fd356b056b62593494772a2061993 (diff)
downloadDevHive-Angular-e4fc300d2fe82084c67c50258c76b60248850863.tar
DevHive-Angular-e4fc300d2fe82084c67c50258c76b60248850863.tar.gz
DevHive-Angular-e4fc300d2fe82084c67c50258c76b60248850863.zip
Merge branch 'dev' of https://github.com/Team-Kaleidoscope/DevHive-Angular into rating_system
Diffstat (limited to 'src/app/components/post-page/post-page.component.ts')
-rw-r--r--src/app/components/post-page/post-page.component.ts34
1 files changed, 17 insertions, 17 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..a60f4da 100644
--- a/src/app/components/post-page/post-page.component.ts
+++ b/src/app/components/post-page/post-page.component.ts
@@ -6,7 +6,7 @@ import { Guid } from 'guid-typescript';
import { CommentService } from 'src/app/services/comment.service';
import { PostService } from 'src/app/services/post.service';
import { TokenService } from 'src/app/services/token.service';
-import { Post } from 'src/models/post';
+import { Post } from 'src/models/post.model';
import { CloudinaryService } from 'src/app/services/cloudinary.service';
@Component({
@@ -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 {