From 01687004ef4c9154b8809ee798a8bc6f0355cb7b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 12 Aug 2025 12:05:02 -0500 Subject: [PATCH] Add missing props to launchImageLibraryAsync (cherry picked from commit 2e80ae561fd66850f787cac0aae0fa5a6980f8f5) --- src/view/com/composer/SelectMediaBtn.tsx | 20 +++++++++++-------- .../com/composer/text-input/TextInput.tsx | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/view/com/composer/SelectMediaBtn.tsx b/src/view/com/composer/SelectMediaBtn.tsx index 60600cf48a..dc4e4c6bd0 100644 --- a/src/view/com/composer/SelectMediaBtn.tsx +++ b/src/view/com/composer/SelectMediaBtn.tsx @@ -1,5 +1,9 @@ import {useCallback} from 'react' -import {type ImagePickerAsset, launchImageLibraryAsync} from 'expo-image-picker' +import { + type ImagePickerAsset, + launchImageLibraryAsync, + UIImagePickerPreferredAssetRepresentationMode, +} from 'expo-image-picker' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -15,6 +19,7 @@ import { import {getDataUriSize} from '#/lib/media/util' import {isNative, isWeb} from '#/platform/detection' import {type ComposerImage, createComposerImage} from '#/state/gallery' +import {MAX_IMAGES} from '#/view/com/composer/state/composer' import {getVideoMetadata} from '#/view/com/composer/videos/pickVideo' import {atoms as a, useTheme} from '#/alf' import {Button} from '#/components/Button' @@ -275,23 +280,22 @@ export function SelectMediaBtn({disabled, onAdd, onSelectVideo}: Props) { } } - //APiligrim - //Note: selectionLimit doesn't work reliably on Android, so we handle limiting in code - const response = await sheetWrapper( + const {assets} = await sheetWrapper( launchImageLibraryAsync({ exif: false, mediaTypes: ['images', 'videos'], quality: 1, allowsMultipleSelection: true, legacy: true, + selectionLimit: MAX_IMAGES, + preferredAssetRepresentationMode: + UIImagePickerPreferredAssetRepresentationMode.Current, }), ) - if (!response.assets || response.assets.length === 0) { - return - } + if (!assets || assets.length === 0) return - await processSelectedAssets(response.assets) + await processSelectedAssets(assets) }, [ requestPhotoAccessIfNeeded, requestVideoAccessIfNeeded, diff --git a/src/view/com/composer/text-input/TextInput.tsx b/src/view/com/composer/text-input/TextInput.tsx index ea92d0b913..14488b0664 100644 --- a/src/view/com/composer/text-input/TextInput.tsx +++ b/src/view/com/composer/text-input/TextInput.tsx @@ -154,6 +154,7 @@ export const TextInput = forwardRef(function TextInputImpl( } const uris = files.map(f => f.uri) + // TODO const uri = uris.find(isUriImage) if (uri) {