Skip to content

Commit

Permalink
Don't allow download percentage to exceed expectations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Apr 29, 2020
1 parent 97bc084 commit e27542b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion React/Base/RCTJavaScriptLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ - (NSString *)description
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];
Expand Down

0 comments on commit e27542b

Please sign in to comment.