From a43d36578b083a46de1d935e689f1d46ef1e8248 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Wed, 12 May 2021 14:14:36 -0700 Subject: [PATCH] Migrate RCTDevLoadingView off bridge APIs Summary: When RCTDevLoadingView is created, it checks to see if the bridge is loading. If so, displays the loading banner with the bundleURL. This logic is better placed in the bridge, because the bridge is also responsible for updating progress on the DevLoadingView. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D28301524 fbshipit-source-id: fb6c259b546d8cd9e08568a88c7046d06c70ed6f --- React/CoreModules/RCTDevLoadingView.mm | 10 ---------- React/CxxBridge/RCTCxxBridge.mm | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/React/CoreModules/RCTDevLoadingView.mm b/React/CoreModules/RCTDevLoadingView.mm index dd3b994cfa..a4be3ed955 100644 --- a/React/CoreModules/RCTDevLoadingView.mm +++ b/React/CoreModules/RCTDevLoadingView.mm @@ -34,7 +34,6 @@ using namespace facebook::react; dispatch_block_t _initialMessageBlock; } -@synthesize bridge = _bridge; @synthesize bundleManager = _bundleManager; RCT_EXPORT_MODULE() @@ -64,15 +63,6 @@ RCT_EXPORT_MODULE() return YES; } -- (void)setBundleManager:(RCTBundleManager *)bundleManager -{ - _bundleManager = bundleManager; - - if (_bridge.loading) { - [self showWithURL:bundleManager.bundleURL]; - } -} - - (void)clearInitialMessageDelay { if (self->_initialMessageBlock != nil) { diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 2e4bf04813..496b26756f 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -495,6 +495,14 @@ struct RCTInstanceCallback : public InstanceCallback { // Load the source asynchronously, then store it for later execution. dispatch_group_enter(prepareBridge); __block NSData *sourceCode; + +#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include() + { + id loadingView = [self moduleForName:@"DevLoadingView" lazilyLoadIfNecessary:YES]; + [loadingView showWithURL:self.bundleURL]; + } +#endif + [self loadSource:^(NSError *error, RCTSource *source) { if (error) {