From 7a513568a5e82063db8248820ae5fb4c7bca8b5a Mon Sep 17 00:00:00 2001 From: Armaan Ahluwalia Date: Thu, 6 Sep 2018 00:13:27 +0530 Subject: [PATCH] ImagePicker: Handle maxfiles correctly. Adds an option composeMenu.js to pass in a maxFiles number. This is used to make sure the user can only select the correct number of files subject to our max of 4. --- src/compose/ComposeBox.ios.js | 1 + src/compose/ComposeMenu.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compose/ComposeBox.ios.js b/src/compose/ComposeBox.ios.js index 8b1a9457401..a72365b9d5f 100644 --- a/src/compose/ComposeBox.ios.js +++ b/src/compose/ComposeBox.ios.js @@ -407,6 +407,7 @@ class ComposeBox extends PureComponent { onImageSelect={this.handleImageSelect} disableCamera={draftImages && Object.keys(draftImages).length >= 4} disableUpload={draftImages && Object.keys(draftImages).length >= 4} + maxFiles={4 - Object.keys(draftImages).length} /> diff --git a/src/compose/ComposeMenu.js b/src/compose/ComposeMenu.js index ebdcc436f81..1c64703c819 100644 --- a/src/compose/ComposeMenu.js +++ b/src/compose/ComposeMenu.js @@ -20,6 +20,7 @@ type Props = { onImageSelect: Object => void, disableUpload?: boolean, disableCamera?: boolean, + maxFiles?: number, }; /** @@ -76,13 +77,14 @@ class ComposeMenu extends PureComponent { handleImageUpload = () => { const { handleImagePickerResponse } = this; + const { maxFiles } = this.props; ImagePicker.openPicker({ mediaType: 'photo', multiple: true, compressImageMaxWidth: 1600, compressImageMaxHeight: 1600, compressImageQuality: 0.7, - maxFiles: 4, + maxFiles, }) .then(images => { handleImagePickerResponse({