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
This commit is contained in:
Rick Hanlon
2020-04-29 09:24:33 -07:00
committed by Facebook GitHub Bot
parent 97bc0845ec
commit e27542bb13
+3 -1
View File
@@ -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];