mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 18:44:25 +00:00
Configure requiresMainQueueSetup for core modules
Reviewed By: fkgozali Differential Revision: D5528305 fbshipit-source-id: f17cad933685be09784b2246f44baf252bfa5a26
This commit is contained in:
parent
d42ccca2e1
commit
220034c4d4
@ -32,6 +32,11 @@ RCT_EXPORT_MODULE(BlobModule)
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{
|
||||
|
@ -24,38 +24,40 @@
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
return [self initWithUserDefaults:[NSUserDefaults standardUserDefaults]];
|
||||
}
|
||||
|
||||
- (instancetype)initWithUserDefaults:(NSUserDefaults *)defaults
|
||||
{
|
||||
if ((self = [self init])) {
|
||||
_defaults = defaults;
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(userDefaultsDidChange:)
|
||||
name:NSUserDefaultsDidChangeNotification
|
||||
object:_defaults];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_bridge = bridge;
|
||||
|
||||
if (!_defaults) {
|
||||
_defaults = [NSUserDefaults standardUserDefaults];
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(userDefaultsDidChange:)
|
||||
name:NSUserDefaultsDidChangeNotification
|
||||
object:_defaults];
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{@"settings": RCTJSONClean([_defaults dictionaryRepresentation])};
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{@"settings": RCTJSONClean([_defaults dictionaryRepresentation])};
|
||||
}
|
||||
|
||||
- (void)userDefaultsDidChange:(NSNotification *)note
|
||||
{
|
||||
if (_ignoringUpdates) {
|
||||
|
@ -71,7 +71,6 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface RCTModuleInitNotificationRaceTests : XCTestCase <RCTBridgeDelegate>
|
||||
{
|
||||
RCTBridge *_bridge;
|
||||
@ -98,6 +97,10 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
_notificationObserver = [RCTNotificationObserverModule new];
|
||||
_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:nil];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[self->_bridge uiManager] constantsToExport];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
|
@ -13,8 +13,6 @@
|
||||
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@implementation RCTPlatform
|
||||
|
||||
static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
||||
switch(idiom) {
|
||||
case UIUserInterfaceIdiomPhone:
|
||||
@ -30,8 +28,15 @@ static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
||||
}
|
||||
}
|
||||
|
||||
@implementation RCTPlatform
|
||||
|
||||
RCT_EXPORT_MODULE(PlatformConstants)
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
UIDevice *device = [UIDevice currentDevice];
|
||||
|
@ -41,11 +41,9 @@ RCT_EXPORT_MODULE()
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setBridge:(RCTBridge *)bridge
|
||||
|
@ -99,6 +99,11 @@ RCT_EXPORT_MODULE()
|
||||
RCTSwapInstanceMethods([UIWindow class], @selector(motionEnded:withEvent:), @selector(RCT_motionEnded:withEvent:));
|
||||
}
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
|
@ -17,21 +17,7 @@
|
||||
|
||||
NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAccessibilityManagerDidUpdateMultiplierNotification";
|
||||
|
||||
@interface RCTAccessibilityManager ()
|
||||
|
||||
@property (nonatomic, copy) NSString *contentSizeCategory;
|
||||
@property (nonatomic, assign) CGFloat multiplier;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTAccessibilityManager
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
@synthesize multipliers = _multipliers;
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (NSDictionary<NSString *, NSString *> *)JSToUIKitMap
|
||||
static NSString *UIKitCategoryFromJSCategory(NSString *JSCategory)
|
||||
{
|
||||
static NSDictionary *map = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
@ -49,12 +35,26 @@ RCT_EXPORT_MODULE()
|
||||
@"accessibilityExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraLarge,
|
||||
@"accessibilityExtraExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraExtraLarge};
|
||||
});
|
||||
return map;
|
||||
return map[JSCategory];
|
||||
}
|
||||
|
||||
+ (NSString *)UIKitCategoryFromJSCategory:(NSString *)JSCategory
|
||||
@interface RCTAccessibilityManager ()
|
||||
|
||||
@property (nonatomic, copy) NSString *contentSizeCategory;
|
||||
@property (nonatomic, assign) CGFloat multiplier;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTAccessibilityManager
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
@synthesize multipliers = _multipliers;
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return [self JSToUIKitMap][JSCategory];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
@ -71,7 +71,7 @@ RCT_EXPORT_MODULE()
|
||||
selector:@selector(didReceiveNewVoiceOverStatus:)
|
||||
name:UIAccessibilityVoiceOverStatusChanged
|
||||
object:nil];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(accessibilityAnnouncementDidFinish:)
|
||||
name:UIAccessibilityAnnouncementDidFinishNotification
|
||||
@ -112,7 +112,7 @@ RCT_EXPORT_MODULE()
|
||||
// Response dictionary to populate the event with.
|
||||
NSDictionary *response = @{@"announcement": userInfo[UIAccessibilityAnnouncementKeyStringValue],
|
||||
@"success": userInfo[UIAccessibilityAnnouncementKeyWasSuccessful]};
|
||||
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"announcementDidFinish"
|
||||
@ -176,7 +176,7 @@ RCT_EXPORT_METHOD(setAccessibilityContentSizeMultipliers:(NSDictionary *)JSMulti
|
||||
NSMutableDictionary<NSString *, NSNumber *> *multipliers = [NSMutableDictionary new];
|
||||
for (NSString *__nonnull JSCategory in JSMultipliers) {
|
||||
NSNumber *m = [RCTConvert NSNumber:JSMultipliers[JSCategory]];
|
||||
NSString *UIKitCategory = [[self class] UIKitCategoryFromJSCategory:JSCategory];
|
||||
NSString *UIKitCategory = UIKitCategoryFromJSCategory(JSCategory);
|
||||
multipliers[UIKitCategory] = m;
|
||||
}
|
||||
self.multipliers = multipliers;
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
static NSString *RCTCurrentAppBackgroundState()
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
static NSDictionary *states;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
@ -41,6 +39,13 @@ static NSString *RCTCurrentAppBackgroundState()
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
// UIApplication.applicationState seems reasonably safe to access from
|
||||
// a background thread.
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
{
|
||||
return dispatch_get_main_queue();
|
||||
|
@ -132,6 +132,11 @@ static NSString *const kRCTDevSettingsUserDefaultsKey = @"RCTDevMenu";
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return YES; // RCT_DEV-only
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
// default behavior is to use NSUserDefaults
|
||||
|
@ -24,6 +24,11 @@
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
{
|
||||
return dispatch_get_main_queue();
|
||||
|
@ -14,6 +14,11 @@
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(allowRTL:(BOOL)value)
|
||||
{
|
||||
[[RCTI18nUtil sharedInstance] allowRTL:value];
|
||||
|
@ -17,6 +17,11 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{
|
||||
|
@ -77,6 +77,11 @@ NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotif
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
/**
|
||||
|
@ -131,11 +131,9 @@ static vm_size_t RCTGetResidentMemorySize(void)
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (instancetype)init
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
// We're only overriding this to ensure the module gets created at startup
|
||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
||||
return [super init];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
|
Loading…
x
Reference in New Issue
Block a user