Skip to content

Commit

Permalink
Fix error state
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Apr 12, 2022
1 parent 8f44d8a commit 9352a19
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions packages/editor/src/components/post-featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ function PostFeaturedImage( { noticeUI, noticeOperations } ) {
);

function onUpdateImage( image ) {
if ( isBlobURL( image.url ) ) {
if ( isBlobURL( image?.url ) ) {
setIsLoading( true );
return;
}

editPost( { featured_media: image.id } );
editPost( { featured_media: image?.id } );
setIsLoading( false );
}

Expand Down Expand Up @@ -223,6 +223,7 @@ function PostFeaturedImage( { noticeUI, noticeOperations } ) {
) }
{ isLoading && <Spinner /> }
{ ! featuredImageId &&
! isLoading &&
( postLabel.set_featured_image ||
DEFAULT_SET_FEATURE_IMAGE_LABEL ) }
</Button>
Expand All @@ -232,27 +233,28 @@ function PostFeaturedImage( { noticeUI, noticeOperations } ) {
value={ featuredImageId }
/>
</MediaUploadCheck>
{ !! featuredImageId && media && (
<MediaUploadCheck>
<MediaUpload
title={
postLabel.featured_image ||
DEFAULT_FEATURE_IMAGE_LABEL
}
onSelect={ onUpdateImage }
unstableFeaturedImageFlow
allowedTypes={ ALLOWED_MEDIA_TYPES }
modalClass="editor-post-featured-image__media-modal"
render={ ( { open } ) => (
<Button onClick={ open } variant="secondary">
{ __( 'Replace Image' ) }
</Button>
) }
/>
</MediaUploadCheck>
) }
{ !! featuredImageId && (
<MediaUploadCheck>
{ media && (
<MediaUpload
title={
postLabel.featured_image ||
DEFAULT_FEATURE_IMAGE_LABEL
}
onSelect={ onUpdateImage }
unstableFeaturedImageFlow
allowedTypes={ ALLOWED_MEDIA_TYPES }
modalClass="editor-post-featured-image__media-modal"
render={ ( { open } ) => (
<Button
onClick={ open }
variant="secondary"
>
{ __( 'Replace Image' ) }
</Button>
) }
/>
) }
<Button
onClick={ onRemoveImage }
variant="link"
Expand Down

0 comments on commit 9352a19

Please sign in to comment.