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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

VideoPress: fix replace video by uploading a new file issue
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ const usePosterAndTitleUpdate = ( { setAttributes, videoData, onDone } ) => {

Promise.allSettled( updates ).then( () => {
setIsFinishingUpdate( false );
setAttributes( videoData );
onDone();
onDone( videoData );
} );
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,19 @@ export default function VideoPressEdit( {

// Render uploading block view
if ( isUploadingFile ) {
const handleDoneUpload = () => {
const handleDoneUpload = newVideoData => {
setIsUploadingFile( false );
if ( isReplacingFile.isReplacing ) {
const newBlockAttributes = {
...attributes,
...newVideoData,
};

// Delete attributes that are not needed.
delete newBlockAttributes.poster;

setIsReplacingFile( { isReplacing: false, prevAttrs: {} } );
replaceBlock( clientId, createBlock( 'videopress/video', { ...attributes } ) );
replaceBlock( clientId, createBlock( 'videopress/video', newBlockAttributes ) );
}
};

Expand Down Expand Up @@ -498,8 +506,12 @@ export default function VideoPressEdit( {
setFileToUpload( media );
} }
onSelectVideoFromLibrary={ media => {
const mediaGuid = media.videopress_guid?.[ 0 ] ?? media.videopress_guid;
// Depending on the endpoint, `videopress_guid` can be an array or a string.
const mediaGuid = Array.isArray( media.videopress_guid )
? media.videopress_guid[ 0 ]
: media.videopress_guid;
if ( ! mediaGuid ) {
debug( 'No media guid provided' );
return;
}

Expand Down