Skip to content

Commit

Permalink
[React Native] request cancel image upload (#14391)
Browse files Browse the repository at this point in the history
* added hook blocks.onRemoveBlockCheckUpload called in componentWillUnmount to make sure to cancel upload if block is deleted

* removed unused import

* moving bridge-specific code to Image component - if the filter exists and returns true, the upload cancellation will be requested

* using hook actions instead of filters
  • Loading branch information
mzorz authored and Tug committed Mar 21, 2019
1 parent 475fa28 commit 87a8ca4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import {
} from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
import { isURL } from '@wordpress/url';
import { doAction, hasAction } from '@wordpress/hooks';


/**
* Internal dependencies
Expand Down Expand Up @@ -87,6 +89,10 @@ 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 )
}
this.removeMediaUploadListener();
}

Expand Down

0 comments on commit 87a8ca4

Please sign in to comment.