From 9bedac205c16a1000886d226d42b90dfe0f105b7 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 25 May 2022 17:26:34 +0530 Subject: [PATCH 1/2] Fix #41311 --- packages/block-library/src/avatar/hooks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/avatar/hooks.js b/packages/block-library/src/avatar/hooks.js index fcc7090547b14..ab633a09b6871 100644 --- a/packages/block-library/src/avatar/hooks.js +++ b/packages/block-library/src/avatar/hooks.js @@ -76,10 +76,10 @@ export function useUserAvatar( { userId, postId, postType } ) { }, [ postType, postId, userId ] ); - const avatarUrls = authorDetails + const avatarUrls = authorDetails && authorDetails.avatar_urls !== undefined ? Object.values( authorDetails.avatar_urls ) : null; - const sizes = authorDetails + const sizes = authorDetails && authorDetails.avatar_urls !== undefined ? Object.keys( authorDetails.avatar_urls ) : null; const { minSize, maxSize } = getAvatarSizes( sizes ); From c8c81ea9983c6c216cf7cdecba2bf8385c640e5b Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Tue, 7 Jun 2022 16:16:14 +0200 Subject: [PATCH 2/2] Update linter recommendations --- packages/block-library/src/avatar/hooks.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/avatar/hooks.js b/packages/block-library/src/avatar/hooks.js index ab633a09b6871..4394fd65a6da8 100644 --- a/packages/block-library/src/avatar/hooks.js +++ b/packages/block-library/src/avatar/hooks.js @@ -76,12 +76,14 @@ export function useUserAvatar( { userId, postId, postType } ) { }, [ postType, postId, userId ] ); - const avatarUrls = authorDetails && authorDetails.avatar_urls !== undefined - ? Object.values( authorDetails.avatar_urls ) - : null; - const sizes = authorDetails && authorDetails.avatar_urls !== undefined - ? Object.keys( authorDetails.avatar_urls ) - : null; + const avatarUrls = + authorDetails && authorDetails.avatar_urls !== undefined + ? Object.values( authorDetails.avatar_urls ) + : null; + const sizes = + authorDetails && authorDetails.avatar_urls !== undefined + ? Object.keys( authorDetails.avatar_urls ) + : null; const { minSize, maxSize } = getAvatarSizes( sizes ); const defaultAvatar = useDefaultAvatar(); return {