mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix NativeLinking split
Summary: In D24324247 (https://github.com/facebook/react-native/commit/56c363e39af6488904cbfd2046314c45babeb0f4), I split NativeLinking into NativeLinkingManager and NativeIntentAndroid. There was this line in NativeLinking.js, that I didn't migrate correctly: ``` export default ((Platform.OS === 'android' ? TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid') : TurboModuleRegistry.getEnforcing<Spec>('LinkingManager')): Spec); ``` I separated this conditional statement into two others: ``` export default TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid'); export default TurboModuleRegistry.getEnforcing<Spec>('LinkingManager'); ``` The problem here is that now on iOS, we're hard requiring IntentAndroid, and on Android, we're hard requiring LinkingManager. Understandably, this started throwing errors in our e2e infra. This diff fixes this problem by: 1. Changing the relevant `getEnforcing` calls into `get` calls. 2. Wrapping all usages of NativeIntentAndroid, and NativeLinkingManager, which are already guarded by `Platform.OS` checks, by a nullthrows. This should satisfy flow. **Note:** NativeIntentAndroid is only used on Android, where it must be available. Similarly, NativeLinkingManager is only used on iOS, where it must be available. Changelog: [Internal] build-break overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: fbandroid_sheriff Differential Revision: D24338558 fbshipit-source-id: b0d22cba77e67837834269deaa317dc73d2457dc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0cec0134e6
commit
b70152cdef
@@ -16,6 +16,7 @@ import Platform from '../Utilities/Platform';
|
||||
import NativeLinkingManager from './NativeLinkingManager';
|
||||
import NativeIntentAndroid from './NativeIntentAndroid';
|
||||
import invariant from 'invariant';
|
||||
import nullthrows from 'nullthrows';
|
||||
|
||||
/**
|
||||
* `Linking` gives you a general interface to interact with both incoming
|
||||
@@ -25,7 +26,7 @@ import invariant from 'invariant';
|
||||
*/
|
||||
class Linking extends NativeEventEmitter {
|
||||
constructor() {
|
||||
super(Platform.OS === 'ios' ? NativeLinkingManager : undefined);
|
||||
super(Platform.OS === 'ios' ? nullthrows(NativeLinkingManager) : undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,9 +56,9 @@ class Linking extends NativeEventEmitter {
|
||||
openURL(url: string): Promise<void> {
|
||||
this._validateURL(url);
|
||||
if (Platform.OS === 'android') {
|
||||
return NativeIntentAndroid.openURL(url);
|
||||
return nullthrows(NativeIntentAndroid).openURL(url);
|
||||
} else {
|
||||
return NativeLinkingManager.openURL(url);
|
||||
return nullthrows(NativeLinkingManager).openURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +70,9 @@ class Linking extends NativeEventEmitter {
|
||||
canOpenURL(url: string): Promise<boolean> {
|
||||
this._validateURL(url);
|
||||
if (Platform.OS === 'android') {
|
||||
return NativeIntentAndroid.canOpenURL(url);
|
||||
return nullthrows(NativeIntentAndroid).canOpenURL(url);
|
||||
} else {
|
||||
return NativeLinkingManager.canOpenURL(url);
|
||||
return nullthrows(NativeLinkingManager).canOpenURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +83,9 @@ class Linking extends NativeEventEmitter {
|
||||
*/
|
||||
openSettings(): Promise<void> {
|
||||
if (Platform.OS === 'android') {
|
||||
return NativeIntentAndroid.openSettings();
|
||||
return nullthrows(NativeIntentAndroid).openSettings();
|
||||
} else {
|
||||
return NativeLinkingManager.openSettings();
|
||||
return nullthrows(NativeLinkingManager).openSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +98,9 @@ class Linking extends NativeEventEmitter {
|
||||
getInitialURL(): Promise<?string> {
|
||||
return Platform.OS === 'android'
|
||||
? InteractionManager.runAfterInteractions().then(() =>
|
||||
NativeIntentAndroid.getInitialURL(),
|
||||
nullthrows(NativeIntentAndroid).getInitialURL(),
|
||||
)
|
||||
: NativeLinkingManager.getInitialURL();
|
||||
: nullthrows(NativeLinkingManager).getInitialURL();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -118,7 +119,7 @@ class Linking extends NativeEventEmitter {
|
||||
}>,
|
||||
): Promise<void> {
|
||||
if (Platform.OS === 'android') {
|
||||
return NativeIntentAndroid.sendIntent(action, extras);
|
||||
return nullthrows(NativeIntentAndroid).sendIntent(action, extras);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => reject(new Error('Unsupported')));
|
||||
}
|
||||
|
||||
@@ -28,4 +28,4 @@ export interface Spec extends TurboModule {
|
||||
) => Promise<void>;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid'): Spec);
|
||||
export default (TurboModuleRegistry.get<Spec>('IntentAndroid'): ?Spec);
|
||||
|
||||
@@ -25,4 +25,4 @@ export interface Spec extends TurboModule {
|
||||
+removeListeners: (count: number) => void;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.getEnforcing<Spec>('LinkingManager'): Spec);
|
||||
export default (TurboModuleRegistry.get<Spec>('LinkingManager'): ?Spec);
|
||||
|
||||
Reference in New Issue
Block a user