Skip to content

Commit

Permalink
Unbreak SurfaceRegistry users in bridge mode
Browse files Browse the repository at this point in the history
Summary: Changelog: [Internal]

Reviewed By: nlutsenko

Differential Revision: D37250414

fbshipit-source-id: be3b98ba661c6f267d0d0dcac8d816584ef58c51
  • Loading branch information
RSNara authored and facebook-github-bot committed Jun 17, 2022
1 parent 4a7e4b9 commit 168f020
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,25 @@ void SurfaceRegistryBinding::startSurface(
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"runApplication",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
if (moduleName != "LogBox" &&
global.hasProperty(runtime, "RN$SurfaceRegistry")) {
auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry");
auto method = registry.getPropertyAsFunction(runtime, "renderSurface");

method.call(
runtime,
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"runApplication",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
}
}
}

Expand Down Expand Up @@ -86,13 +98,25 @@ void SurfaceRegistryBinding::setSurfaceProps(
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"setSurfaceProps",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
if (moduleName != "LogBox" &&
global.hasProperty(runtime, "RN$SurfaceRegistry")) {
auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry");
auto method = registry.getPropertyAsFunction(runtime, "setSurfaceProps");

method.call(
runtime,
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
callMethodOfModule(
runtime,
"AppRegistry",
"setSurfaceProps",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
}
}
}

Expand Down

0 comments on commit 168f020

Please sign in to comment.