mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-06 22:37:14 +08:00
Remove android initialAppState fallback check (#23487)
Summary: 1. We expose the `initialAppState` for Android in #19935, so we can remove the fallback check for Android. 2. Rename `RCTCurrentAppBackgroundState` to `RCTCurrentAppState`, it's a private file function, so it's safe to rename, `RCTCurrentAppState` is more suitable because we actually get app state, not app background state. [Android] [Enhancement] - Remove android `initialAppState` fallback check. Pull Request resolved: https://github.com/facebook/react-native/pull/23487 Differential Revision: D14121293 Pulled By: cpojer fbshipit-source-id: fec196cef2969fe6f6f1571f4ebcafcec26266a1
This commit is contained in:
committed by
Facebook Github Bot
parent
5560a47c1d
commit
f95876ba8c
@@ -38,9 +38,7 @@ class AppState extends NativeEventEmitter {
|
||||
memoryWarning: new Map(),
|
||||
};
|
||||
|
||||
// TODO: Remove the 'active' fallback after `initialAppState` is exported by
|
||||
// the Android implementation.
|
||||
this.currentState = RCTAppState.initialAppState || 'active';
|
||||
this.currentState = RCTAppState.initialAppState;
|
||||
|
||||
let eventUpdated = false;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
static NSString *RCTCurrentAppBackgroundState()
|
||||
static NSString *RCTCurrentAppState()
|
||||
{
|
||||
static NSDictionary *states;
|
||||
static dispatch_once_t onceToken;
|
||||
@@ -54,7 +54,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (NSDictionary *)getConstants
|
||||
{
|
||||
return @{@"initialAppState": RCTCurrentAppBackgroundState()};
|
||||
return @{@"initialAppState": RCTCurrentAppState()};
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
@@ -105,7 +105,7 @@ RCT_EXPORT_MODULE()
|
||||
} else if ([notification.name isEqualToString:UIApplicationWillEnterForegroundNotification]) {
|
||||
newState = @"background";
|
||||
} else {
|
||||
newState = RCTCurrentAppBackgroundState();
|
||||
newState = RCTCurrentAppState();
|
||||
}
|
||||
|
||||
if (![newState isEqualToString:_lastKnownState]) {
|
||||
@@ -123,7 +123,7 @@ RCT_EXPORT_MODULE()
|
||||
RCT_EXPORT_METHOD(getCurrentAppState:(RCTResponseSenderBlock)callback
|
||||
error:(__unused RCTResponseSenderBlock)error)
|
||||
{
|
||||
callback(@[@{@"app_state": RCTCurrentAppBackgroundState()}]);
|
||||
callback(@[@{@"app_state": RCTCurrentAppState()}]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user