From 131c497aa2c081f9dfd03e45b25fb7ae388b98bd Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Tue, 28 Apr 2020 23:16:58 -0700 Subject: [PATCH] Do not update loading banner message while hiding Summary: This diff fixes an issue where the loading banner message could update while the banner hide animation is going, catching your eye for no reason. Changelog: [Fixed] [iOS] Do not update loading banner message while hiding Reviewed By: PeteTheHeat Differential Revision: D21280786 fbshipit-source-id: a10b33cd72f263d08eea6d8e94963514affbe24d --- React/CoreModules/RCTDevLoadingView.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/React/CoreModules/RCTDevLoadingView.mm b/React/CoreModules/RCTDevLoadingView.mm index 9a4c4453d7b..6dd3d6f46eb 100644 --- a/React/CoreModules/RCTDevLoadingView.mm +++ b/React/CoreModules/RCTDevLoadingView.mm @@ -31,6 +31,7 @@ using namespace facebook::react; UILabel *_label; UILabel *_host; NSDate *_showDate; + BOOL _hiding; } @synthesize bridge = _bridge; @@ -85,7 +86,7 @@ RCT_EXPORT_MODULE() - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor { - if (!RCTDevLoadingViewGetEnabled()) { + if (!RCTDevLoadingViewGetEnabled() || self->_hiding) { return; } @@ -159,6 +160,7 @@ RCT_EXPORT_METHOD(hide) } dispatch_async(dispatch_get_main_queue(), ^{ + self->_hiding = true; const NSTimeInterval MIN_PRESENTED_TIME = 0.6; NSTimeInterval presentedTime = [[NSDate date] timeIntervalSinceDate:self->_showDate]; NSTimeInterval delay = MAX(0, MIN_PRESENTED_TIME - presentedTime); @@ -173,6 +175,7 @@ RCT_EXPORT_METHOD(hide) self->_window.frame = windowFrame; self->_window.hidden = YES; self->_window = nil; + self->_hiding = false; }]; }); }