diff --git a/src/app/components/feed/feed.component.ts b/src/app/components/feed/feed.component.ts index ad17f55..44eee90 100644 --- a/src/app/components/feed/feed.component.ts +++ b/src/app/components/feed/feed.component.ts @@ -63,6 +63,9 @@ export class FeedComponent implements OnInit { this.feedService.postsAvailable.subscribe(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) { this.posting = true; this.feedService.createPostActivity(postElement.value, activityId, this.file).subscribe(() => { - this.posting = false; 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.posting = false; this.errorOccurred = true; this.errorMessage = error.error.errors[0].message; }); } else if (postElement) { this.posting = true; this.feedService.createPost(postElement.value, this.file).subscribe((result) => { - console.log('response in component'); - this.posting = false; 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('an error occured in component'); console.log(error); - this.posting = false; this.errorOccurred = true; this.errorMessage = error.error.errors[0].message; }); @@ -120,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 = ''; diff --git a/src/app/components/feed/postlist/postlist.component.html b/src/app/components/feed/postlist/postlist.component.html index 50f13eb..2ffa144 100644 --- a/src/app/components/feed/postlist/postlist.component.html +++ b/src/app/components/feed/postlist/postlist.component.html @@ -22,9 +22,10 @@ -
- post image -