Skip to content
Merged
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
17 changes: 6 additions & 11 deletions packages/block-library/src/video/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Disabled,
PanelBody,
Spinner,
withNotices,
} from '@wordpress/components';
import {
BlockControls,
Expand All @@ -31,9 +30,10 @@ import {
import { useRef, useEffect } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { useInstanceId } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import { video as icon } from '@wordpress/icons';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
import { store as noticesStore } from '@wordpress/notices';

/**
* Internal dependencies
Expand All @@ -48,13 +48,11 @@ const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];

function VideoEdit( {
isSelected,
noticeUI,
attributes,
className,
setAttributes,
insertBlocksAfter,
onReplace,
noticeOperations,
} ) {
const instanceId = useInstanceId( VideoEdit );
const videoPlayer = useRef();
Expand All @@ -73,9 +71,7 @@ function VideoEdit( {
mediaUpload( {
filesList: [ file ],
onFileChange: ( [ media ] ) => onSelectVideo( media ),
onError: ( message ) => {
noticeOperations.createErrorNotice( message );
},
onError: onUploadError,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just simplified logic here by reusing callback.

allowedTypes: ALLOWED_MEDIA_TYPES,
} );
}
Expand Down Expand Up @@ -126,9 +122,9 @@ function VideoEdit( {
}
}

const { createErrorNotice } = useDispatch( noticesStore );
function onUploadError( message ) {
noticeOperations.removeAllNotices();
noticeOperations.createErrorNotice( message );
createErrorNotice( message, { type: 'snackbar' } );
}

const classes = classnames( className, {
Expand All @@ -149,7 +145,6 @@ function VideoEdit( {
accept="video/*"
allowedTypes={ ALLOWED_MEDIA_TYPES }
value={ attributes }
notices={ noticeUI }
onError={ onUploadError }
/>
</div>
Expand Down Expand Up @@ -289,4 +284,4 @@ function VideoEdit( {
);
}

export default withNotices( VideoEdit );
export default VideoEdit;