diff --git a/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js b/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js index 4b3c1b7f8eec3..738d83a789a2b 100644 --- a/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js +++ b/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js @@ -350,10 +350,14 @@ define([ _VIDEO_URL_VALIDATE_TRIGGER: 'validate_video_url', + _CANCEL_VIDEO_INFORMATION_TRIGGER: 'cancelled_video_information', + _videoInformation: null, _currentVideoUrl: null, + _shouldCancelVideoRequest: false, + /** * @private */ @@ -366,6 +370,11 @@ define([ }, this )); this.element.on(this._VIDEO_URL_VALIDATE_TRIGGER, $.proxy(this._onUrlValidateHandler, this)); + this.element.on(this._CANCEL_VIDEO_INFORMATION_TRIGGER, $.proxy( + function () { + this._shouldCancelVideoRequest = true; + }, this + )); }, /** @@ -395,6 +404,8 @@ define([ id, googleapisUrl; + this._shouldCancelVideoRequest = false; + if (this._currentVideoUrl === url) { return; } @@ -471,6 +482,10 @@ define([ return; } + if (this._shouldCancelVideoRequest) { + return; + } + tmp = data.items[0]; uploadedFormatted = tmp.snippet.publishedAt.replace('T', ' ').replace(/\..+/g, ''); respData = { @@ -502,6 +517,10 @@ define([ return null; } + + if (this._shouldCancelVideoRequest) { + return; + } tmp = data; respData = { duration: this._formatVimeoDuration(tmp.duration), diff --git a/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js b/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js index 562bff2e1d472..460406c77a78c 100644 --- a/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js +++ b/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js @@ -246,6 +246,8 @@ define([ _gallery: null, + _isUpdatingVideo: false, + /** * Bind events * @private @@ -335,6 +337,7 @@ define([ _onGetVideoInformationSuccess: function (e, data) { var self = this; + this._isUpdatingVideo = true; self.element.on('finish_update_video finish_create_video', $.proxy(function (element, playerData) { if (!self._onlyVideoPlayer || !self._isEditPage && playerData.oldVideoId !== playerData.newVideoId || @@ -395,6 +398,9 @@ define([ data: 'remote_image=' + sourceUrl, type: 'post', success: $.proxy(function (result) { + if (!self._isUpdatingVideo) { + return; + } this._tempPreviewImageData = result; this._getPreviewImage().attr('src', sourceUrl).show(); this._blockActionButtons(false, true); @@ -722,6 +728,7 @@ define([ modalTitleElement = modal.find('.modal-title'); if (!file) { + widget._videoUrlWidget.trigger('cancelled_video_information'); widget._blockActionButtons(true); modal.find('.video-delete-button').hide(); @@ -1097,12 +1104,14 @@ define([ this._isEditPage = true; this.imageData = null; + this._isUpdatingVideo = false; if (this._previewImage) { this._previewImage.remove(); this._previewImage = null; } this._tempPreviewImageData = null; + this._videoUrlWidget.trigger('cancelled_video_information'); this.element.trigger('reset'); newVideoForm = this.element.find(this._videoFormSelector);