Skip to content

Commit

Permalink
[RNMobile] Prevent error message from unneccesarily firing when uploa…
Browse files Browse the repository at this point in the history
…ding to Gallery block (#46175)

This PR ensures that any valid image uploaded to the Gallery block within the mobile apps is correctly marked as valid.
  • Loading branch information
Siobhan Bamber committed Nov 30, 2022
1 parent 4791d12 commit 05bab5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,19 @@ 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 nativeFileData =
Platform.isNative && file.id
? find( imageData, { id: file.id } )
: null;

const mediaTypeSelector = nativeFileData
? nativeFileData?.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
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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]
Expand Down

0 comments on commit 05bab5a

Please sign in to comment.