Skip to content

Commit

Permalink
removes useless editing and src state
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Jan 6, 2020
1 parent 7a81852 commit 960fdaa
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions packages/block-library/src/video/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ class VideoEdit extends Component {
super( ...arguments );
// edit component has its own src in the state so it can be edited
// without setting the actual value outside of the edit UI
this.state = {
editing: ! this.props.attributes.src,
};

this.videoPlayer = createRef();
this.posterImageButton = createRef();
this.onSelectURL = this.onSelectURL.bind( this );
Expand All @@ -76,7 +72,6 @@ class VideoEdit extends Component {
setAttributes( { src: url } );
},
onError: ( message ) => {
this.setState( { editing: true } );
noticeOperations.createErrorNotice( message );
},
allowedTypes: ALLOWED_MEDIA_TYPES,
Expand All @@ -95,8 +90,7 @@ class VideoEdit extends Component {
const { attributes, setAttributes } = this.props;
const { src } = attributes;

// Set the block's src from the edit component's state, and switch off
// the editing UI.
// Set the block's src from the edit component's state
if ( newSrc !== src ) {
// Check if there's an embed block that handles this URL.
const embedBlock = createUpgradedEmbedBlock(
Expand All @@ -108,8 +102,6 @@ class VideoEdit extends Component {
}
setAttributes( { src: newSrc, id: undefined } );
}

this.setState( { editing: false } );
}

onSelectPoster( image ) {
Expand Down Expand Up @@ -148,15 +140,15 @@ class VideoEdit extends Component {
} = this.props;
const onSelectVideo = ( media ) => {
if ( ! media || ! media.url ) {
// in this case there was an error and we should continue in the editing state
// previous attributes should be removed because they may be temporary blob urls
// in this case there was an error
// previous attributes should be removed
// because they may be temporary blob urls
setAttributes( { src: undefined, id: undefined } );
return;
}
// sets the block's attribute and updates the edit component from the
// selected media, then switches off the editing UI
// selected media
setAttributes( { src: media.url, id: media.id } );
this.setState( { src: media.url, editing: false } );
};

if ( ! src ) {
Expand Down

0 comments on commit 960fdaa

Please sign in to comment.