From e3c46bf2307dd422f5d67eea0310ca0b5f554e47 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 20 Dec 2022 14:01:25 +0200 Subject: [PATCH] [Inserter]: Try fix media tab when upload of media types has been disabled --- .../src/components/inserter/media-tab/hooks.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/inserter/media-tab/hooks.js b/packages/block-editor/src/components/inserter/media-tab/hooks.js index f537dce68608a..e3b68510d77d2 100644 --- a/packages/block-editor/src/components/inserter/media-tab/hooks.js +++ b/packages/block-editor/src/components/inserter/media-tab/hooks.js @@ -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 } ) =>