From 2827c6f20c9da35e21f03479ed755e63f482c7db Mon Sep 17 00:00:00 2001 From: Siobhan Date: Tue, 29 Nov 2022 21:09:44 +0000 Subject: [PATCH 1/5] Ensure native images are marked as valid The existing 'isValidFileType' function doesn't always return true when it should for native images. This is because of a difference in the way data is retrieved for images on native. This commit updates the function to account for that difference. --- packages/block-library/src/gallery/edit.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/gallery/edit.js b/packages/block-library/src/gallery/edit.js index 6d1a4ac5fc404..63beee8d262ba 100644 --- a/packages/block-library/src/gallery/edit.js +++ b/packages/block-library/src/gallery/edit.js @@ -217,9 +217,17 @@ function GalleryEdit( props ) { } function isValidFileType( file ) { + // It's necessary to retrieve the media type from the raw image data for uploaded images on native. + const image = + Platform.isNative && file.id + ? find( imageData, { id: file.id } ) + : null; + + const mediaTypeSelector = image ? image?.media_type : file.type; + return ( ALLOWED_MEDIA_TYPES.some( - ( mediaType ) => file.type?.indexOf( mediaType ) === 0 + ( mediaType ) => mediaTypeSelector?.indexOf( mediaType ) === 0 ) || file.url?.indexOf( 'blob:' ) === 0 ); } From 8f8bfb7bfeced793cacacdf71ac7ebb6517d62be Mon Sep 17 00:00:00 2001 From: Siobhan Date: Tue, 29 Nov 2022 21:44:07 +0000 Subject: [PATCH 2/5] Update CHANGELOG --- packages/react-native-editor/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 2cd7647c0e0f6..30a63254c969b 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -11,6 +11,7 @@ For each user feature we should also add a importance categorization label to i ## Unreleased +- [**] Prevent error message from unneccesarily firing when uploading to Gallery block [#46175] ## 1.85.0 - [*] [iOS] Fixed iOS Voice Control support within Image block captions. [#44850] From 9fd94d03ffa608a0b590e87ab464be9364736d00 Mon Sep 17 00:00:00 2001 From: Siobhan Date: Tue, 29 Nov 2022 21:45:33 +0000 Subject: [PATCH 3/5] Fix formatting issues in CHANGELOG --- packages/react-native-editor/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 30a63254c969b..15d077d642295 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -10,8 +10,8 @@ For each user feature we should also add a importance categorization label to i --> ## Unreleased - - [**] Prevent error message from unneccesarily firing when uploading to Gallery block [#46175] + ## 1.85.0 - [*] [iOS] Fixed iOS Voice Control support within Image block captions. [#44850] From 54decbe79c13ec461a57d512884bddb56cbe915b Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 30 Nov 2022 10:23:01 +0000 Subject: [PATCH 4/5] Refine variable naming for clarity --- packages/block-library/src/gallery/edit.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/gallery/edit.js b/packages/block-library/src/gallery/edit.js index 63beee8d262ba..6de7d4a4016ac 100644 --- a/packages/block-library/src/gallery/edit.js +++ b/packages/block-library/src/gallery/edit.js @@ -217,13 +217,15 @@ function GalleryEdit( props ) { } function isValidFileType( file ) { - // It's necessary to retrieve the media type from the raw image data for uploaded images on native. - const image = + // It's necessary to retrieve the media type from the raw image data for already-uploaded images on native. + const nativeBlockData = Platform.isNative && file.id ? find( imageData, { id: file.id } ) : null; - const mediaTypeSelector = image ? image?.media_type : file.type; + const mediaTypeSelector = nativeBlockData + ? nativeBlockData?.media_type + : file.type; return ( ALLOWED_MEDIA_TYPES.some( From 61a0b9d4380992da6d7e35c2c4d90584fce3bf73 Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 30 Nov 2022 11:52:11 +0000 Subject: [PATCH 5/5] Update variable name for clarity and accuracy --- packages/block-library/src/gallery/edit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/gallery/edit.js b/packages/block-library/src/gallery/edit.js index 6de7d4a4016ac..30ecdee0f00b5 100644 --- a/packages/block-library/src/gallery/edit.js +++ b/packages/block-library/src/gallery/edit.js @@ -218,13 +218,13 @@ function GalleryEdit( props ) { function isValidFileType( file ) { // It's necessary to retrieve the media type from the raw image data for already-uploaded images on native. - const nativeBlockData = + const nativeFileData = Platform.isNative && file.id ? find( imageData, { id: file.id } ) : null; - const mediaTypeSelector = nativeBlockData - ? nativeBlockData?.media_type + const mediaTypeSelector = nativeFileData + ? nativeFileData?.media_type : file.type; return (