Skip to content

Commit

Permalink
Fix BlobModule getConstants()
Browse files Browse the repository at this point in the history
Summary:
It's possible for us to return no constants from the BlobModule. Therefore, I'm correcting the flow-type.

Changelog:
[Internal]

Reviewed By: fkgozali

Differential Revision: D18932328

fbshipit-source-id: 2b415d12effd16eda313d5591825c711a20f9ae3
  • Loading branch information
RSNara authored and facebook-github-bot committed Dec 11, 2019
1 parent e1e081b commit a8fbc5b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Libraries/Blob/NativeBlobModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {TurboModule} from '../TurboModule/RCTExport';
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
+getConstants: () => {|BLOB_URI_SCHEME: string, BLOB_URI_HOST: ?string|};
+getConstants: () => {|BLOB_URI_SCHEME: ?string, BLOB_URI_HOST: ?string|};
+addNetworkingHandler: () => void;
+addWebSocketHandler: (id: number) => void;
+removeWebSocketHandler: (id: number) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ public NativeBlobModuleSpec(ReactApplicationContext reactContext) {
public final @Nullable Map<String, Object> getConstants() {
Map<String, Object> constants = getTypedExportedConstants();
if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
"BLOB_URI_SCHEME"
));
Set<String> obligatoryFlowConstants = new HashSet<>();
Set<String> optionalFlowConstants = new HashSet<>(Arrays.asList(
"BLOB_URI_HOST"
"BLOB_URI_HOST",
"BLOB_URI_SCHEME"
));
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
undeclaredConstants.removeAll(obligatoryFlowConstants);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public String getName() {
String packageName = getReactApplicationContext().getPackageName();
int resourceId = resources.getIdentifier("blob_provider_authority", "string", packageName);
if (resourceId == 0) {
return null;
return MapBuilder.<String, Object>of();
}

return MapBuilder.<String, Object>of(
Expand Down

0 comments on commit a8fbc5b

Please sign in to comment.