diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-02-25 14:19:59 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-02-25 14:19:59 +0200 |
| commit | b7a574bfaeacda2ed26033572b52f0c0c93ec9cb (patch) | |
| tree | 8002af57197194337d2f7b57b6336eb170263600 /src/app | |
| parent | d9d76c97bd76ddd503739d94f88eb15905bb4f3b (diff) | |
| download | DevHive-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.ts | 20 |
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; } |
