Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to put the action name in some constant so that we can reuse it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following with comment here wordpress-mobile/gutenberg-mobile#736 (comment)

Another thing I just noticed is that the constant would need to be defined in gutenberg-mobile and be imported in Gutenberg native file (as those are the 2 places where it's used, for adding in the Gutenberg-mobile level and removing at the Gutenberg component level) - I don't think there's much gain as there's 2 places only, been thinking of doing it through props as well, but it makes the code a small bit harder to follow. Would it be ok to leave it as is ? wdyt?

doAction( 'blocks.onRemoveBlockCheckUpload', this.props.attributes.id )
}
this.removeMediaUploadListener();
}

Expand Down