From c4eb41aee24dc6b2cead0ee45a1a38b5883703fe Mon Sep 17 00:00:00 2001 From: Matthew Kevins Date: Thu, 7 Nov 2019 11:53:06 +1000 Subject: [PATCH] [RNMobile] Gallery - Add append logic to MediaPlaceholder (#18262) * Add append logic to MediaPlaceholder for gallery * Fix lint errors --- .../src/components/media-placeholder/index.native.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/media-placeholder/index.native.js b/packages/block-editor/src/components/media-placeholder/index.native.js index 3680401362a4cb..05ba33de28cf77 100644 --- a/packages/block-editor/src/components/media-placeholder/index.native.js +++ b/packages/block-editor/src/components/media-placeholder/index.native.js @@ -2,6 +2,7 @@ * External dependencies */ import { View, Text, TouchableWithoutFeedback } from 'react-native'; +import { uniqBy } from 'lodash'; /** * WordPress dependencies @@ -22,6 +23,7 @@ import styles from './styles.scss'; function MediaPlaceholder( props ) { const { + addToGallery, allowedTypes = [], labels = {}, icon, @@ -30,8 +32,13 @@ function MediaPlaceholder( props ) { disableMediaButtons, getStylesFromColorScheme, multiple, + value = [], } = props; + const setMedia = multiple && addToGallery ? + ( selected ) => onSelect( uniqBy( [ ...value, ...selected ], 'id' ) ) : + onSelect; + const isOneType = allowedTypes.length === 1; const isImage = isOneType && allowedTypes.includes( MEDIA_TYPE_IMAGE ); const isVideo = isOneType && allowedTypes.includes( MEDIA_TYPE_VIDEO ); @@ -103,7 +110,7 @@ function MediaPlaceholder( props ) { { return (