Skip to content

Commit

Permalink
Do not update loading banner message while hiding
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Apr 29, 2020
1 parent 3729fe8 commit 131c497
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion React/CoreModules/RCTDevLoadingView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ @implementation RCTDevLoadingView {
UILabel *_label;
UILabel *_host;
NSDate *_showDate;
BOOL _hiding;
}

@synthesize bridge = _bridge;
Expand Down Expand Up @@ -85,7 +86,7 @@ - (NSString *)getTextForHost

- (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor
{
if (!RCTDevLoadingViewGetEnabled()) {
if (!RCTDevLoadingViewGetEnabled() || self->_hiding) {
return;
}

Expand Down Expand Up @@ -159,6 +160,7 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
}

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);
Expand All @@ -173,6 +175,7 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
self->_window.frame = windowFrame;
self->_window.hidden = YES;
self->_window = nil;
self->_hiding = false;
}];
});
}
Expand Down

0 comments on commit 131c497

Please sign in to comment.