ImagePicker always called with cancelCallback

Summary: We should pick 2 callbacks from pickerCallbacks and pickerCancelCallbacks arrays and call them depens on args.
Closes https://github.com/facebook/react-native/pull/4411

Reviewed By: svcscm

Differential Revision: D2703209

Pulled By: javache

fb-gh-sync-id: 7d2d7c63b933a66a1ff600663c3a7fcc821c750b
This commit is contained in:
Aleksei Androsov 2015-11-30 10:28:49 -08:00 committed by facebook-github-bot-0
parent 32fa0b7fa1
commit 015c6b3be2
1 changed files with 7 additions and 2 deletions

View File

@ -132,7 +132,8 @@ didFinishPickingMediaWithInfo:(NSDictionary<NSString *, id> *)info
- (void)_dismissPicker:(UIImagePickerController *)picker args:(NSArray *)args
{
NSUInteger index = [_pickers indexOfObject:picker];
RCTResponseSenderBlock callback = _pickerCancelCallbacks[index];
RCTResponseSenderBlock successCallback = _pickerCallbacks[index];
RCTResponseSenderBlock cancelCallback = _pickerCancelCallbacks[index];
[_pickers removeObjectAtIndex:index];
[_pickerCallbacks removeObjectAtIndex:index];
@ -141,7 +142,11 @@ didFinishPickingMediaWithInfo:(NSDictionary<NSString *, id> *)info
UIViewController *rootViewController = RCTKeyWindow().rootViewController;
[rootViewController dismissViewControllerAnimated:YES completion:nil];
callback(args ?: @[]);
if (args) {
successCallback(args);
} else {
cancelCallback(@[]);
}
}
@end