Skip to content

Commit

Permalink
[Inserter]: Try fix media tab when upload of media types has been dis…
Browse files Browse the repository at this point in the history
…abled (#46676)
  • Loading branch information
ntsekouras authored Dec 22, 2022
1 parent 99bc9c7 commit 972c0ce
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ export function useMediaCategories( rootClientId ) {
per_page: 1,
_fields: [ 'id' ],
};
const [ image, video, audio ] = await Promise.all( [
const [ image, video, audio ] = await Promise.allSettled( [
fetchMedia( { ...query, media_type: 'image' } ),
fetchMedia( { ...query, media_type: 'video' } ),
fetchMedia( { ...query, media_type: 'audio' } ),
] );
const showImage = canInsertImage && !! image.length;
const showVideo = canInsertVideo && !! video.length;
const showAudio = canInsertAudio && !! audio.length;
// The `value` property is only present if the promise's status is "fulfilled".
const showImage = canInsertImage && !! image.value?.length;
const showVideo = canInsertVideo && !! video.value?.length;
const showAudio = canInsertAudio && !! audio.value?.length;
setCategories(
MEDIA_CATEGORIES.filter(
( { mediaType } ) =>
Expand Down

1 comment on commit 972c0ce

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3757482926
📝 Reported issues:

Please sign in to comment.