From d554ba3a11d500141bcb05303426def8b432471c Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Fri, 14 Jun 2019 17:30:39 +0200 Subject: [PATCH] Call requestImageUploadCancel directly instead of running hook --- .../components/block-list/block-mobile-toolbar.native.js | 7 +++++-- packages/block-library/src/image/edit.native.js | 7 +++---- packages/block-library/src/video/edit.native.js | 7 +++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-mobile-toolbar.native.js b/packages/block-editor/src/components/block-list/block-mobile-toolbar.native.js index d2e66d24c0419e..3bcbe6f0f83899 100644 --- a/packages/block-editor/src/components/block-list/block-mobile-toolbar.native.js +++ b/packages/block-editor/src/components/block-list/block-mobile-toolbar.native.js @@ -38,12 +38,15 @@ const BlockMobileToolbar = ( { ); export default compose( - withDispatch( ( dispatch, { clientId, rootClientId } ) => { + withDispatch( ( dispatch, { clientId, rootClientId, onDelete } ) => { const { removeBlock } = dispatch( 'core/block-editor' ); return { - onDelete: () => { + onDelete() { Keyboard.dismiss(); removeBlock( clientId, rootClientId ); + if ( onDelete ) { + onDelete( clientId ); + } }, }; } ), diff --git a/packages/block-library/src/image/edit.native.js b/packages/block-library/src/image/edit.native.js index cb0cc5a9302630..d7ade08d4f5c94 100644 --- a/packages/block-library/src/image/edit.native.js +++ b/packages/block-library/src/image/edit.native.js @@ -8,6 +8,7 @@ import { mediaUploadSync, requestImageFailedRetryDialog, requestImageUploadCancelDialog, + requestImageUploadCancel, } from 'react-native-gutenberg-bridge'; import { isEmpty } from 'lodash'; @@ -30,7 +31,6 @@ import { } from '@wordpress/block-editor'; import { __, sprintf } from '@wordpress/i18n'; import { isURL } from '@wordpress/url'; -import { doAction, hasAction } from '@wordpress/hooks'; /** * Internal dependencies @@ -92,9 +92,8 @@ class ImageEdit extends React.Component { } componentWillUnmount() { - // this action will only exist if the user pressed the trash button on the block holder - if ( hasAction( 'blocks.onRemoveBlockCheckUpload' ) && this.state.isUploadInProgress ) { - doAction( 'blocks.onRemoveBlockCheckUpload', this.props.attributes.id ); + if ( this.state.isUploadInProgress ) { + requestImageUploadCancel( this.props.attributes.id ); } } diff --git a/packages/block-library/src/video/edit.native.js b/packages/block-library/src/video/edit.native.js index 1b7fc518313440..c7d041cd725552 100644 --- a/packages/block-library/src/video/edit.native.js +++ b/packages/block-library/src/video/edit.native.js @@ -11,6 +11,7 @@ import { mediaUploadSync, requestImageFailedRetryDialog, requestImageUploadCancelDialog, + requestImageUploadCancel, } from 'react-native-gutenberg-bridge'; /** @@ -31,7 +32,6 @@ import { } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { isURL } from '@wordpress/url'; -import { doAction, hasAction } from '@wordpress/hooks'; /** * Internal dependencies @@ -70,9 +70,8 @@ class VideoEdit extends React.Component { } componentWillUnmount() { - // this action will only exist if the user pressed the trash button on the block holder - if ( hasAction( 'blocks.onRemoveBlockCheckUpload' ) && this.state.isUploadInProgress ) { - doAction( 'blocks.onRemoveBlockCheckUpload', this.props.attributes.id ); + if ( this.state.isUploadInProgress ) { + requestImageUploadCancel( this.props.attributes.id ); } }