Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 14 additions & 1 deletion packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ImageEdit extends React.Component {
this.removeMediaUploadListener = this.removeMediaUploadListener.bind( this );
this.finishMediaUploadWithSuccess = this.finishMediaUploadWithSuccess.bind( this );
this.finishMediaUploadWithFailure = this.finishMediaUploadWithFailure.bind( this );
this.updateMediaProgress = this.updateMediaProgress.bind( this );
this.updateAlt = this.updateAlt.bind( this );
this.updateImageURL = this.updateImageURL.bind( this );
this.onSetLinkDestination = this.onSetLinkDestination.bind( this );
Expand Down Expand Up @@ -106,7 +107,7 @@ class ImageEdit extends React.Component {

switch ( payload.state ) {
case MEDIA_UPLOAD_STATE_UPLOADING:
this.setState( { progress: payload.progress, isUploadInProgress: true, isUploadFailed: false } );
this.updateMediaProgress( payload );
break;
case MEDIA_UPLOAD_STATE_SUCCEEDED:
this.finishMediaUploadWithSuccess( payload );
Expand All @@ -120,6 +121,14 @@ class ImageEdit extends React.Component {
}
}

updateMediaProgress( payload ) {
const { setAttributes } = this.props;
this.setState( { progress: payload.progress, isUploadInProgress: true, isUploadFailed: false } );
if ( payload.mediaUrl !== undefined ) {
setAttributes( { url: payload.mediaUrl } );
}
}

finishMediaUploadWithSuccess( payload ) {
const { setAttributes } = this.props;

Expand All @@ -144,6 +153,10 @@ class ImageEdit extends React.Component {
}

addMediaUploadListener() {
//if we already have a subscription not worth doing it again
if ( this.subscriptionParentMediaUpload ) {
return;
}
this.subscriptionParentMediaUpload = subscribeMediaUpload( ( payload ) => {
this.mediaUpload( payload );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ class BottomSheet extends Component {
}

componentDidMount() {
SafeArea.addEventListener( 'safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsUpdate );
this.eventSubscription = SafeArea.addEventListener( 'safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsUpdate );
}

componentWillUnmount() {
this.eventSubscription.remove();
this.eventSubscription = null;
SafeArea.removeEventListener( 'safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsUpdate );
}

onSafeAreaInsetsUpdate( result ) {
if ( this.eventSubscription === null ) {
return;
}
const { safeAreaInsets } = result;
if ( this.state.safeAreaBottomInset !== safeAreaInsets.bottom ) {
this.setState( { safeAreaBottomInset: safeAreaInsets.bottom } );
Expand Down