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

Loading…
Cancel
Save