From 5d62ed6cc9a5ef1d021710e24f9d7ee846cd06a9 Mon Sep 17 00:00:00 2001 From: Danilo Ercoli Date: Tue, 25 Jun 2019 12:33:38 +0200 Subject: [PATCH 1/2] Revert "Re-enable Video block on Android after Android X migration (#16215)" This reverts commit 284bb1781457941eb38a2b080d926ffdcc416e01. --- packages/edit-post/src/index.native.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js index 6a2d926d2c193d..f22a57dea55f3d 100644 --- a/packages/edit-post/src/index.native.js +++ b/packages/edit-post/src/index.native.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import { Platform } from 'react-native'; + /** * WordPress dependencies */ @@ -24,6 +29,11 @@ export function initializeEditor() { // eslint-disable-next-line no-undef if ( typeof __DEV__ === 'undefined' || ! __DEV__ ) { unregisterBlockType( 'core/code' ); + + // Disable Video block except for iOS for now. + if ( Platform.OS !== 'ios' ) { + unregisterBlockType( 'core/video' ); + } } } From 3fc8ba6874e934a7e890f3e86420ad3a06a9ec8c Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Fri, 28 Jun 2019 17:46:15 +0300 Subject: [PATCH 2/2] Don't forcefully cancel media upload on img/video unmount Manually reverts d554ba3a11d500141bcb05303426def8b432471c --- .../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, 10 insertions(+), 11 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 e5ac71ee27ed34..96395c41c835f2 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 @@ -55,15 +55,12 @@ export default compose( order: getBlockIndex( clientId ), }; } ), - withDispatch( ( dispatch, { clientId, rootClientId, onDelete } ) => { + withDispatch( ( dispatch, { clientId, rootClientId } ) => { 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 d7ade08d4f5c94..cb0cc5a9302630 100644 --- a/packages/block-library/src/image/edit.native.js +++ b/packages/block-library/src/image/edit.native.js @@ -8,7 +8,6 @@ import { mediaUploadSync, requestImageFailedRetryDialog, requestImageUploadCancelDialog, - requestImageUploadCancel, } from 'react-native-gutenberg-bridge'; import { isEmpty } from 'lodash'; @@ -31,6 +30,7 @@ import { } from '@wordpress/block-editor'; import { __, sprintf } from '@wordpress/i18n'; import { isURL } from '@wordpress/url'; +import { doAction, hasAction } from '@wordpress/hooks'; /** * Internal dependencies @@ -92,8 +92,9 @@ class ImageEdit extends React.Component { } componentWillUnmount() { - if ( this.state.isUploadInProgress ) { - requestImageUploadCancel( this.props.attributes.id ); + // 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 ); } } diff --git a/packages/block-library/src/video/edit.native.js b/packages/block-library/src/video/edit.native.js index c7d041cd725552..1b7fc518313440 100644 --- a/packages/block-library/src/video/edit.native.js +++ b/packages/block-library/src/video/edit.native.js @@ -11,7 +11,6 @@ import { mediaUploadSync, requestImageFailedRetryDialog, requestImageUploadCancelDialog, - requestImageUploadCancel, } from 'react-native-gutenberg-bridge'; /** @@ -32,6 +31,7 @@ import { } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { isURL } from '@wordpress/url'; +import { doAction, hasAction } from '@wordpress/hooks'; /** * Internal dependencies @@ -70,8 +70,9 @@ class VideoEdit extends React.Component { } componentWillUnmount() { - if ( this.state.isUploadInProgress ) { - requestImageUploadCancel( this.props.attributes.id ); + // 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 ); } }