Change feedservice to delete post when media upload fails

master
Max 5 years ago
parent 5b2b5c0936
commit 8845d591e9

@ -194,6 +194,7 @@ 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 (result.success) {
if (this.activePostList === Sort.NEW) { if (this.activePostList === Sort.NEW) {
post.mediaUrl = result.fileName; post.mediaUrl = result.fileName;
post.mediaType = result.fileName.endsWith('.png') ? 'IMAGE' : 'VIDEO'; post.mediaType = result.fileName.endsWith('.png') ? 'IMAGE' : 'VIDEO';
@ -201,10 +202,15 @@ export class FeedService extends BaseService {
this.posts.next(updatedPosts); this.posts.next(updatedPosts);
this.posting.next(false); this.posting.next(false);
} }
} else {
console.error(result.error);
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