fix(js) provide default value for optional ‘assetType’

This commit is contained in:
Bartol Karuza 2019-03-03 20:46:47 +08:00
parent 8c8c0fe921
commit 0d1059ef75
3 changed files with 6 additions and 1 deletions

View File

@ -10,6 +10,7 @@
'use strict'; 'use strict';
import RNCCameraRoll from './nativeInterface'; import RNCCameraRoll from './nativeInterface';
const invariant = require('fbjs/lib/invariant'); const invariant = require('fbjs/lib/invariant');
const GROUP_TYPES_OPTIONS = { const GROUP_TYPES_OPTIONS = {
@ -159,6 +160,9 @@ class CameraRoll {
* See https://facebook.github.io/react-native/docs/cameraroll.html#getphotos * See https://facebook.github.io/react-native/docs/cameraroll.html#getphotos
*/ */
static getPhotos(params: GetPhotosParams): Promise<PhotoIdentifiersPage> { static getPhotos(params: GetPhotosParams): Promise<PhotoIdentifiersPage> {
if (!params.assetType) {
params.assetType = ASSET_TYPE_OPTIONS.All;
}
if (arguments.length > 1) { if (arguments.length > 1) {
console.warn( console.warn(
'CameraRoll.getPhotos(tag, success, error) is deprecated. Use the returned Promise instead', 'CameraRoll.getPhotos(tag, success, error) is deprecated. Use the returned Promise instead',

View File

@ -14,6 +14,7 @@ exports[`CameraRoll Should call getPhotos 1`] = `
Array [ Array [
Array [ Array [
Object { Object {
"assetType": "All",
"first": 0, "first": 0,
}, },
], ],

View File

@ -29,7 +29,7 @@ export interface GetPhotosParams {
groupName?: string, groupName?: string,
assetType?: AssetType assetType?: AssetType
mimeTypes?: Array<string>, mimeTypes?: Array<string>,
}; }
export interface PhotoIdentifier { export interface PhotoIdentifier {
node: { node: {