Skip to content

Commit

Permalink
Clear bundler banner messages after a certain delay during developmen…
Browse files Browse the repository at this point in the history
…t. (#38355)

Summary:
Pull Request resolved: #38355

Changelog: [General] [iOS] Clear bundler banner messages after a certain delay during development.

Reviewed By: cipolleschi

Differential Revision: D47478373

fbshipit-source-id: e171ec714fc13096adfd4811f2007ff3e37cbf38
  • Loading branch information
jacdebug authored and facebook-github-bot committed Jul 19, 2023
1 parent 256aaa1 commit 6eeb81a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/react-native/React/CoreModules/RCTDevLoadingView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ - (void)showInitialMessageDelayed:(void (^)())initialMessage
dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), self->_initialMessageBlock);
}

- (void)hideBannerAfter:(CGFloat)delay
{
// Cancel previous hide call after the delay.
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hide) object:nil];
// Set new hide call after a delay.
[self performSelector:@selector(hide) withObject:nil afterDelay:delay];
}

- (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor
{
if (!RCTDevLoadingViewGetEnabled() || _hiding) {
Expand Down Expand Up @@ -132,6 +140,8 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
UIWindowScene *scene = (UIWindowScene *)RCTSharedApplication().connectedScenes.anyObject;
self->_window.windowScene = scene;
});

[self hideBannerAfter:15.0];
}

RCT_EXPORT_METHOD(showMessage
Expand Down

0 comments on commit 6eeb81a

Please sign in to comment.