From d579a10ba169d6e95e8ea8a9d7f2821fe89bca1f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 17 Jul 2020 18:03:08 +0200 Subject: media form tweaks. copy a media item to avoid typing in properties. --- .../frontend/views/media/components/media.formImage.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'animism-align/frontend/views/media/components/media.formImage.js') diff --git a/animism-align/frontend/views/media/components/media.formImage.js b/animism-align/frontend/views/media/components/media.formImage.js index abd0f94..4a97112 100644 --- a/animism-align/frontend/views/media/components/media.formImage.js +++ b/animism-align/frontend/views/media/components/media.formImage.js @@ -86,19 +86,23 @@ export default class MediaImageForm extends Component { // when we upload an image, if the image already exists in this "position" // on the record, we should also delete it if (this.props.data.settings[tag] && this.props.data.settings[tag].id) { - return actions.upload.destroy(this.props.data.settings[tag]) - .then(() => { - return this.uploadTaggedSize(image, tag, fn) - }) - .catch(() => { - console.log('error deleting the image') - return this.uploadTaggedSize(image, tag, fn) + return new Promise((resolve, reject) => { + actions.upload.destroy(this.props.data.settings[tag]) + .then(() => { + console.log('destroy successful') + this.uploadTaggedSize(image, tag, fn).then(data => resolve(data)) + }) + .catch(() => { + console.log('error deleting the image') + this.uploadTaggedSize(image, tag, fn).then(data => resolve(data)) + }) }) } return this.uploadTaggedSize(image, tag, fn) } uploadTaggedSize(image, tag, fn) { + console.log('uploading size', tag) const uploadData = { image, tag, -- cgit v1.2.3-70-g09d2