|
|
@ -63,6 +63,9 @@ export class FeedComponent implements OnInit {
|
|
|
|
this.feedService.postsAvailable.subscribe(available => {
|
|
|
|
this.feedService.postsAvailable.subscribe(available => {
|
|
|
|
this.loadingMostLiked = this.loadingNew = available;
|
|
|
|
this.loadingMostLiked = this.loadingNew = available;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.feedService.posting.subscribe(posting => {
|
|
|
|
|
|
|
|
this.posting = posting;
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -74,39 +77,19 @@ export class FeedComponent implements OnInit {
|
|
|
|
if (postElement && activityId && this.checked) {
|
|
|
|
if (postElement && activityId && this.checked) {
|
|
|
|
this.posting = true;
|
|
|
|
this.posting = true;
|
|
|
|
this.feedService.createPostActivity(postElement.value, activityId, this.file).subscribe(() => {
|
|
|
|
this.feedService.createPostActivity(postElement.value, activityId, this.file).subscribe(() => {
|
|
|
|
this.posting = false;
|
|
|
|
|
|
|
|
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.posting = false;
|
|
|
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
this.errorOccurred = true;
|
|
|
|
this.errorMessage = error.error.errors[0].message;
|
|
|
|
this.errorMessage = error.error.errors[0].message;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (postElement) {
|
|
|
|
} else if (postElement) {
|
|
|
|
this.posting = true;
|
|
|
|
this.posting = true;
|
|
|
|
this.feedService.createPost(postElement.value, this.file).subscribe((result) => {
|
|
|
|
this.feedService.createPost(postElement.value, this.file).subscribe((result) => {
|
|
|
|
console.log('response in component');
|
|
|
|
|
|
|
|
this.posting = false;
|
|
|
|
|
|
|
|
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('an error occured in component');
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
this.posting = false;
|
|
|
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
this.errorOccurred = true;
|
|
|
|
this.errorMessage = error.error.errors[0].message;
|
|
|
|
this.errorMessage = error.error.errors[0].message;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -120,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 = '';
|
|
|
|