Change feedservice to delete post when media upload fails

master
Max 5 years ago
parent 5b2b5c0936
commit 8845d591e9

@ -194,17 +194,23 @@ export class FeedService extends BaseService {
const updatedPosts = this.posts.getValue(); const updatedPosts = this.posts.getValue();
const post = this.constructPost(response); const post = this.constructPost(response);
this.uploadPostImage(post.id, file).subscribe((result) => { this.uploadPostImage(post.id, file).subscribe((result) => {
if (this.activePostList === Sort.NEW) { if (result.success) {
post.mediaUrl = result.fileName; if (this.activePostList === Sort.NEW) {
post.mediaType = result.fileName.endsWith('.png') ? 'IMAGE' : 'VIDEO'; post.mediaUrl = result.fileName;
updatedPosts.unshift(post); post.mediaType = result.fileName.endsWith('.png') ? 'IMAGE' : 'VIDEO';
this.posts.next(updatedPosts); updatedPosts.unshift(post);
this.posts.next(updatedPosts);
this.posting.next(false);
}
} else {
console.error(result.error);
this.posting.next(false); this.posting.next(false);
this.deletePost(post.id).subscribe();
} }
}, error => { }, error => {
console.error(error); console.error(error);
this.posting.next(false); this.posting.next(false);
this.deletePost(post.id); this.deletePost(post.id).subscribe();
}); });
} }
)); ));

Loading…
Cancel
Save