Improve code in feed component

master
Max 5 years ago
parent 8f8a9cf64e
commit 34d75b6544

@ -78,14 +78,7 @@ export class FeedComponent implements OnInit {
this.posting = true;
this.feedService.createPostActivity(postElement.value, activityId, this.file).subscribe(() => {
postElement.value = '';
this.textInputValue = '';
this.checked = false;
this.file = null;
this.localFileUrl = null;
this.fileType = null;
if (this.view !== 'new') {
this.showNew();
}
this.resetPostInput();
}, (error: IErrorResponse) => {
this.errorOccurred = true;
this.errorMessage = error.error.errors[0].message;
@ -94,14 +87,7 @@ export class FeedComponent implements OnInit {
this.posting = true;
this.feedService.createPost(postElement.value, this.file).subscribe((result) => {
postElement.value = '';
this.textInputValue = '';
this.checked = false;
this.file = null;
this.localFileUrl = null;
this.fileType = null;
if (this.view !== 'new') {
this.showNew();
}
this.resetPostInput();
}, (error: IErrorResponse) => {
console.log(error);
this.errorOccurred = true;
@ -117,6 +103,15 @@ export class FeedComponent implements OnInit {
this.fileInput.nativeElement.value = '';
}
resetPostInput() {
this.textInputValue = '';
this.checked = false;
this.discardFile();
if (this.view !== 'new') {
this.showNew();
}
}
onFileInputChange(event) {
this.errorOccurred = false;
this.errorMessage = '';

Loading…
Cancel
Save