From dbbfc470eb587cf124969a06cac65dcb2fd7153d Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 24 Jan 2020 21:38:42 +0100 Subject: [PATCH] Change function in feedService --- src/app/services/feed/feed.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/services/feed/feed.service.ts b/src/app/services/feed/feed.service.ts index 1333f15..9f0a8fd 100644 --- a/src/app/services/feed/feed.service.ts +++ b/src/app/services/feed/feed.service.ts @@ -192,21 +192,22 @@ export class FeedService extends BaseService { return this.postGraphql(body, null, 0) .pipe(tap(response => { const updatedPosts = this.posts.getValue(); - if (this.activePostList === Sort.NEW) { - const post = this.constructPost(response); - this.uploadPostImage(post.id, file).subscribe((result) => { + const post = this.constructPost(response); + this.uploadPostImage(post.id, file).subscribe((result) => { + if (this.activePostList === Sort.NEW) { post.mediaUrl = result.fileName; post.mediaType = result.fileName.endsWith('.png') ? 'IMAGE' : 'VIDEO'; updatedPosts.unshift(post); this.posts.next(updatedPosts); this.posting.next(false); + } }, error => { console.error(error); this.posting.next(false); this.deletePost(post.id); }); } - })); + )); } else if (!file) { return this.postGraphql(body, null, 0) .pipe(tap(response => {