Skip to content

Commit 015c6b3

Browse files
doochikfacebook-github-bot-0
authored andcommitted
ImagePicker always called with cancelCallback
Summary: We should pick 2 callbacks from pickerCallbacks and pickerCancelCallbacks arrays and call them depens on args. Closes #4411 Reviewed By: svcscm Differential Revision: D2703209 Pulled By: javache fb-gh-sync-id: 7d2d7c63b933a66a1ff600663c3a7fcc821c750b
1 parent 32fa0b7 commit 015c6b3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Libraries/CameraRoll/RCTImagePickerManager.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ - (void)_presentPicker:(UIImagePickerController *)imagePicker
132132
- (void)_dismissPicker:(UIImagePickerController *)picker args:(NSArray *)args
133133
{
134134
NSUInteger index = [_pickers indexOfObject:picker];
135-
RCTResponseSenderBlock callback = _pickerCancelCallbacks[index];
135+
RCTResponseSenderBlock successCallback = _pickerCallbacks[index];
136+
RCTResponseSenderBlock cancelCallback = _pickerCancelCallbacks[index];
136137

137138
[_pickers removeObjectAtIndex:index];
138139
[_pickerCallbacks removeObjectAtIndex:index];
@@ -141,7 +142,11 @@ - (void)_dismissPicker:(UIImagePickerController *)picker args:(NSArray *)args
141142
UIViewController *rootViewController = RCTKeyWindow().rootViewController;
142143
[rootViewController dismissViewControllerAnimated:YES completion:nil];
143144

144-
callback(args ?: @[]);
145+
if (args) {
146+
successCallback(args);
147+
} else {
148+
cancelCallback(@[]);
149+
}
145150
}
146151

147152
@end

0 commit comments

Comments
 (0)