Skip to content

Commit

Permalink
ImagePicker always called with cancelCallback
Browse files Browse the repository at this point in the history
Summary: We should pick 2 callbacks from pickerCallbacks and pickerCancelCallbacks arrays and call them depens on args.
Closes facebook#4411

Reviewed By: svcscm

Differential Revision: D2703209

Pulled By: javache

fb-gh-sync-id: 7d2d7c63b933a66a1ff600663c3a7fcc821c750b
  • Loading branch information
doochik authored and facebook-github-bot-0 committed Nov 30, 2015
1 parent 32fa0b7 commit 015c6b3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Libraries/CameraRoll/RCTImagePickerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ - (void)_presentPicker:(UIImagePickerController *)imagePicker
- (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];
Expand All @@ -141,7 +142,11 @@ - (void)_dismissPicker:(UIImagePickerController *)picker args:(NSArray *)args
UIViewController *rootViewController = RCTKeyWindow().rootViewController;
[rootViewController dismissViewControllerAnimated:YES completion:nil];

callback(args ?: @[]);
if (args) {
successCallback(args);
} else {
cancelCallback(@[]);
}
}

@end

0 comments on commit 015c6b3

Please sign in to comment.