Skip to content

Commit

Permalink
Address some oxlint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Dec 13, 2023
1 parent 4b30e68 commit 671dbd4
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 214 deletions.
12 changes: 5 additions & 7 deletions packages/edit-post/src/blockMediaPanel/coverControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ export function CoverControls( props: CoverControlsProps ) {
onSuccess={ onChange }
/>
{ 'video' === props.attributes.backgroundType ? (
<>
<MuteVideo
id={ props.attributes.id }
url={ props.attributes.url }
onChange={ onChange }
/>
</>
<MuteVideo
id={ props.attributes.id }
url={ props.attributes.url }
onChange={ onChange }
/>
) : null }
<DebugInfo id={ props.attributes.id } />
</Fragment>
Expand Down
48 changes: 8 additions & 40 deletions packages/edit-post/src/blockMediaPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,59 +43,27 @@ type PerBlockControlsProps = MediaPanelProps;
function PerBlockControls( props: PerBlockControlsProps ) {
switch ( props.name ) {
case 'core/video':
return (
<>
<VideoControls { ...props } />
</>
);
return <VideoControls { ...props } />;
case 'core/image':
return (
<>
<ImageControls { ...props } />
</>
);
return <ImageControls { ...props } />;

case 'core/audio':
return (
<>
<AudioControls { ...props } />
</>
);
return <AudioControls { ...props } />;

case 'core/media-text':
return (
<>
<MediaTextControls { ...props } />
</>
);
return <MediaTextControls { ...props } />;

case 'core/gallery':
return (
<>
<GalleryControls { ...props } />
</>
);
return <GalleryControls { ...props } />;

case 'core/cover':
return (
<>
<CoverControls { ...props } />
</>
);
return <CoverControls { ...props } />;

case 'core/post-featured-image':
return (
<>
<PostFeaturedImageControls />
</>
);
return <PostFeaturedImageControls />;

case 'core/site-logo':
return (
<>
<SiteLogoControls { ...props } />
</>
);
return <SiteLogoControls { ...props } />;

default:
return null;
Expand Down
12 changes: 5 additions & 7 deletions packages/edit-post/src/blockMediaPanel/mediaTextControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ export function MediaTextControls( props: MediaTextControlsProps ) {
onSuccess={ onChange }
/>
{ 'video' === props.attributes.mediaType ? (
<>
<MuteVideo
id={ props.attributes.mediaId }
url={ props.attributes.mediaUrl }
onChange={ onChange }
/>
</>
<MuteVideo
id={ props.attributes.mediaId }
url={ props.attributes.mediaUrl }
onChange={ onChange }
/>
) : null }
<DebugInfo id={ props.attributes.mediaId } />
</Fragment>
Expand Down
21 changes: 9 additions & 12 deletions packages/edit-post/src/blockMediaPanel/recordingControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,15 @@ function InputControls() {
} ) );

// Videos can be recorded with or without audio.
const audioControls = [
...audioDevices.map( ( device ) => ( {
title: device.label,
onClick: () => {
void setAudioInput( device.deviceId );
},
isActive: audioInput === device.deviceId,
role: 'menuitemradio',
icon:
hasAudio && audioInput === device.deviceId ? check : undefined,
} ) ),
];
const audioControls = audioDevices.map( ( device ) => ( {
title: device.label,
onClick: () => {
void setAudioInput( device.deviceId );
},
isActive: audioInput === device.deviceId,
role: 'menuitemradio',
icon: hasAudio && audioInput === device.deviceId ? check : undefined,
} ) );

if ( 'video' === recordingType ) {
audioControls.unshift( {
Expand Down
48 changes: 24 additions & 24 deletions packages/edit-post/src/crossOriginIsolation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@ function forceCrossOrigin( imgCrossOrigin: CrossOriginValue, url: string ) {
return 'anonymous' as CrossOriginValue;
}

async function waitForChildren( element: Element ) {
return new Promise< void >( ( resolve ) => {
if ( ! element ) {
return resolve();
}

if ( element.children.length ) {
return resolve();
}

const obs = new MutationObserver( () => {
if ( element.children.length ) {
obs.disconnect();
resolve();
}
} );

obs.observe( element, {
childList: true,
subtree: true,
} );
} );
}

if ( window.crossOriginIsolated ) {
addFilter(
'media.crossOrigin',
Expand Down Expand Up @@ -66,30 +90,6 @@ if ( window.crossOriginIsolated ) {
} );
} );

async function waitForChildren( element: Element ) {
return new Promise< void >( ( resolve ) => {
if ( ! element ) {
return resolve();
}

if ( element.children.length ) {
return resolve();
}

const obs = new MutationObserver( () => {
if ( element.children.length ) {
observer.disconnect();
resolve();
}
} );

obs.observe( element, {
childList: true,
subtree: true,
} );
} );
}

const unsubscribe = subscribe( async () => {
const wrapperEl = document.querySelector(
'.edit-post-layout__metaboxes'
Expand Down
Loading

0 comments on commit 671dbd4

Please sign in to comment.