Skip to content

Commit

Permalink
Call requestImageUploadCancel directly instead of running hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Tug committed Jun 18, 2019
1 parent 0872cca commit d554ba3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
},
};
} ),
Expand Down
7 changes: 3 additions & 4 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
mediaUploadSync,
requestImageFailedRetryDialog,
requestImageUploadCancelDialog,
requestImageUploadCancel,
} from 'react-native-gutenberg-bridge';
import { isEmpty } from 'lodash';

Expand All @@ -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
Expand Down Expand Up @@ -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 );
}
}

Expand Down
7 changes: 3 additions & 4 deletions packages/block-library/src/video/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
mediaUploadSync,
requestImageFailedRetryDialog,
requestImageUploadCancelDialog,
requestImageUploadCancel,
} from 'react-native-gutenberg-bridge';

/**
Expand All @@ -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
Expand Down Expand Up @@ -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 );
}
}

Expand Down

0 comments on commit d554ba3

Please sign in to comment.