Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Prevent error message from unneccesarily firing when uploading to Gallery block #46175

Merged
merged 5 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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