1111#import " RNNTurboCommandsHandler.h"
1212#import < React-RuntimeApple/ReactCommon/RCTHost.h>
1313
14- @interface RNNTurboManager ()
1514
15+ @interface RNNTurboManager ()
1616@property (nonatomic , strong , readwrite ) RNNExternalComponentStore *store;
1717@property (nonatomic , strong , readwrite ) RNNReactComponentRegistry *componentRegistry;
1818@property (nonatomic , strong , readonly ) RNNLayoutManager *layoutManager;
@@ -21,15 +21,16 @@ @interface RNNTurboManager ()
2121@property (nonatomic , strong , readonly ) RNNModalHostViewManagerHandler *modalHostViewHandler;
2222@property (nonatomic , strong , readonly ) RNNCommandsHandler *commandsHandler;
2323@property (nonatomic , strong , readonly ) RNNEventEmitter *eventEmitter;
24-
2524@end
2625
2726@implementation RNNTurboManager {
2827 UIWindow *_mainWindow;
28+ BOOL _isInitialRun;
2929}
3030
3131- (instancetype )initWithHost : (RCTHost *)host mainWindow : (UIWindow *)mainWindow {
3232 if (self = [super init ]) {
33+ _isInitialRun = YES ;
3334 _host = host;
3435 _mainWindow = mainWindow;
3536 _overlayManager = [RNNOverlayManager new ];
@@ -40,7 +41,12 @@ - (instancetype)initWithHost:(RCTHost *)host mainWindow:(UIWindow *)mainWindow {
4041 name: @" RCTInstanceDidLoadBundle"
4142 object: nil ];
4243
43- // TODO: investigate which new event is fired
44+ [[NSNotificationCenter defaultCenter ] addObserver: self
45+ selector: @selector (onReload )
46+ name: @" RCTTriggerReloadCommandNotification"
47+ object: nil ];
48+
49+ // TODO: investigate which new event is fired
4450 [[NSNotificationCenter defaultCenter ] addObserver: self
4551 selector: @selector (onJavaScriptWillLoad )
4652 name: RCTJavaScriptWillStartLoadingNotification
@@ -99,16 +105,24 @@ - (void)onJavaScriptWillLoad {
99105}
100106
101107- (void )onJavaScriptLoaded {
102- RCTExecuteOnMainQueue (^{
103- UIApplication.sharedApplication .delegate .window .rootViewController = nil ;
104-
105- [self ->_commandsHandler setReadyToReceiveCommands: true ];
106- // TODO: Refactor
107- // [_modalHostViewHandler
108- // connectModalHostViewManager:[[_host moduleRegistry] moduleForName:"RCTModalHostViewManager"]];
109-
110- [self ->_eventEmitter sendOnAppLaunched ];
111- });
108+ RCTExecuteOnMainQueue (^{
109+ // TODO: the isInitialRun is the right and final answer for this, this will stop a blackscreen appearing after the splashscreen on startup. OnReload this will still happen because of the rootViewController = nil; which is needed to clean up what is already appearing.
110+ if (!self->_isInitialRun ) {
111+ UIApplication.sharedApplication .delegate .window .rootViewController = nil ;
112+ }
113+
114+ self-> _isInitialRun = NO ;
115+
116+ [self ->_commandsHandler setReadyToReceiveCommands: true ];
117+ // TODO: Refactor
118+ // [_modalHostViewHandler
119+ // connectModalHostViewManager:[[_host moduleRegistry] moduleForName:"RCTModalHostViewManager"]];
120+
121+ [self ->_eventEmitter sendOnAppLaunched ];
122+ });
123+ }
124+
125+ - (void )onReload {
112126}
113127
114128@end
0 commit comments