mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
RCTImagePicker now uses main thread
Summary: public RCTImagePicker (aka ImagePickerIOS) was previously displaying UI from a random thread, which is unsafe. This diff forces it to execute on the main thread instead. Reviewed By: jspahrsummers Differential Revision: D2657465 fb-gh-sync-id: 3c0fa6935061ccaa3e6ce649b4e3e8ad8c701384
This commit is contained in:
parent
2fb03be046
commit
6dd171b8c2
@ -42,6 +42,11 @@ RCT_EXPORT_MODULE(ImagePickerIOS);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
{
|
||||
return dispatch_get_main_queue();
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(canRecordVideos:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
NSArray<NSString *> *availableMediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
|
||||
|
@ -37,7 +37,8 @@
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view {
|
||||
- (UIView *)view
|
||||
{
|
||||
return [RCTSnapshotView new];
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@ RCT_EXPORT_MODULE()
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
[nc addObserver:self selector:@selector(applicationDidChangeStatusBarFrame:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
||||
[nc addObserver:self selector:@selector(applicationWillChangeStatusBarFrame:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -72,10 +71,10 @@ RCT_EXPORT_MODULE()
|
||||
CGRect frame = [notification.userInfo[UIApplicationStatusBarFrameUserInfoKey] CGRectValue];
|
||||
NSDictionary *event = @{
|
||||
@"frame": @{
|
||||
@"x": @(frame.origin.x),
|
||||
@"y": @(frame.origin.y),
|
||||
@"width": @(frame.size.width),
|
||||
@"height": @(frame.size.height),
|
||||
@"x": @(frame.origin.x),
|
||||
@"y": @(frame.origin.y),
|
||||
@"width": @(frame.size.width),
|
||||
@"height": @(frame.size.height),
|
||||
},
|
||||
};
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:eventName body:event];
|
||||
|
Loading…
x
Reference in New Issue
Block a user