aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-02-25 14:19:59 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-02-25 14:19:59 +0200
commitb7a574bfaeacda2ed26033572b52f0c0c93ec9cb (patch)
tree8002af57197194337d2f7b57b6336eb170263600 /src/app
parentd9d76c97bd76ddd503739d94f88eb15905bb4f3b (diff)
downloadDevHive-Angular-b7a574bfaeacda2ed26033572b52f0c0c93ec9cb.tar
DevHive-Angular-b7a574bfaeacda2ed26033572b52f0c0c93ec9cb.tar.gz
DevHive-Angular-b7a574bfaeacda2ed26033572b52f0c0c93ec9cb.zip
Editing post message has the current message by default and doesn't update if the message isn't changed
Diffstat (limited to 'src/app')
-rw-r--r--src/app/components/post-page/post-page.component.ts20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/app/components/post-page/post-page.component.ts b/src/app/components/post-page/post-page.component.ts
index 413ff80..648048b 100644
--- a/src/app/components/post-page/post-page.component.ts
+++ b/src/app/components/post-page/post-page.component.ts
@@ -44,6 +44,7 @@ export class PostPageComponent implements OnInit {
this.post.fileURLs = Object.values(result)[7];
if (this.loggedIn) {
this.editable = this.post.creatorUsername === this._tokenService.getUsernameFromSessionStorageToken();
+ this.editPostFormGroup.get('newPostMessage')?.setValue(this.post.message);
}
if (this.post.fileURLs.length > 0) {
this.loadFiles();
@@ -116,15 +117,18 @@ export class PostPageComponent implements OnInit {
if (this.editingPost) {
let newMessage = this.editPostFormGroup.get('newPostMessage')?.value;
- if (newMessage === '') {
- newMessage = this.post.message;
- }
- this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe(
- (result: object) => {
- this.reloadPage();
+
+ if (newMessage !== this.post.message) {
+ if (newMessage === '') {
+ newMessage = this.post.message;
}
- );
- this.dataArrived = false;
+ this._postService.putPostWithSessionStorageRequest(this.postId, newMessage, this.files).subscribe(
+ (result: object) => {
+ this.reloadPage();
+ }
+ );
+ this.dataArrived = false;
+ }
}
this.editingPost = !this.editingPost;
}