Skip to content

Commit

Permalink
Fix NativePlatformConstants
Browse files Browse the repository at this point in the history
Summary:
When in debug mode, PlatformConstants doesn't have a `ServerHost` constant. This wasn't captured by `NativePlatformConstants`.

Changelog:
[Android][Fixed] - Make sure ServerHost is optional in NativePlatformConstants.js

Reviewed By: rickhanlonii

Differential Revision: D19091270

fbshipit-source-id: 4b3ac73a4ab6111b3e433ecca01cc769e8cdec6b
  • Loading branch information
RSNara authored and facebook-github-bot committed Dec 18, 2019
1 parent 38af48d commit 048f88a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ namespace JS {
RCTRequired<NSString *> Serial;
RCTRequired<NSString *> Fingerprint;
RCTRequired<NSString *> Model;
RCTRequired<NSString *> ServerHost;
NSString *ServerHost;
RCTRequired<NSString *> uiMode;
};

Expand Down Expand Up @@ -3633,7 +3633,7 @@ inline JS::NativePlatformConstantsAndroid::Constants::Builder::Builder(const Inp
d[@"Fingerprint"] = Fingerprint;
auto Model = i.Model.get();
d[@"Model"] = Model;
auto ServerHost = i.ServerHost.get();
auto ServerHost = i.ServerHost;
d[@"ServerHost"] = ServerHost;
auto uiMode = i.uiMode.get();
d[@"uiMode"] = uiMode;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Utilities/NativePlatformConstantsAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface Spec extends TurboModule {
Serial: string,
Fingerprint: string,
Model: string,
ServerHost: string,
ServerHost?: string,
uiMode: string,
|};
+getAndroidID: () => string;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Utilities/Platform.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Platform = {
Serial: string,
Fingerprint: string,
Model: string,
ServerHost: string,
ServerHost?: string,
uiMode: string,
|} {
if (this.__constants == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public NativePlatformConstantsAndroidSpec(ReactApplicationContext reactContext)
"Version",
"reactNativeVersion",
"Model",
"ServerHost",
"isTesting",
"Release"
));
Set<String> optionalFlowConstants = new HashSet<>();
Set<String> optionalFlowConstants = new HashSet<>(Arrays.asList(
"ServerHost"
));
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
undeclaredConstants.removeAll(obligatoryFlowConstants);
undeclaredConstants.removeAll(optionalFlowConstants);
Expand Down

0 comments on commit 048f88a

Please sign in to comment.