From e27542bb13d1f8f422cd307c4d43148c8bd82bc0 Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Wed, 29 Apr 2020 09:24:33 -0700 Subject: [PATCH] Don't allow download percentage to exceed expectations Summary: This diff updates the loading banner to protect against showing percentages over 100% Changelog: [Fixed] [iOS] Cap loading bar percentage at 100% Reviewed By: shergin Differential Revision: D21295809 fbshipit-source-id: 343f53acafa126800367444562730eff4ae67af4 --- React/Base/RCTJavaScriptLoader.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/React/Base/RCTJavaScriptLoader.mm b/React/Base/RCTJavaScriptLoader.mm index ce347a26ff8..d15738c549e 100755 --- a/React/Base/RCTJavaScriptLoader.mm +++ b/React/Base/RCTJavaScriptLoader.mm @@ -52,7 +52,9 @@ static RCTSource *RCTSourceCreate(NSURL *url, NSData *data, int64_t length) NS_R NSMutableString *desc = [NSMutableString new]; [desc appendString:_status ?: @"Bundling"]; - if ([_total integerValue] > 0) { + if ([_total integerValue] > 0 && [_done integerValue] > [_total integerValue]) { + [desc appendFormat:@" %ld%%", (long)100]; + } else if ([_total integerValue] > 0) { [desc appendFormat:@" %ld%%", (long)(100 * [_done integerValue] / [_total integerValue])]; } else { [desc appendFormat:@" %ld%%", (long)0];