@@ -13,7 +13,7 @@ @implementation CodePush {
1313
1414RCT_EXPORT_MODULE ()
1515
16- static BOOL didRollback = NO;
16+ static BOOL needToReportRollback = NO;
1717static BOOL isRunningBinaryVersion = NO ;
1818static BOOL testConfigurationFlag = NO ;
1919
@@ -195,15 +195,14 @@ - (void)initializeUpdateAfterRestart
195195 NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
196196 NSDictionary *pendingUpdate = [preferences objectForKey: PendingUpdateKey];
197197 if (pendingUpdate) {
198- didRollback = NO ;
199198 _isFirstRunAfterUpdate = YES ;
200199 BOOL updateIsLoading = [pendingUpdate[PendingUpdateIsLoadingKey] boolValue ];
201200 if (updateIsLoading) {
202201 // Pending update was initialized, but notifyApplicationReady was not called.
203202 // Therefore, deduce that it is a broken update and rollback.
204203 NSLog (@" Update did not finish loading the last time, rolling back to a previous version." );
204+ needToReportRollback = YES ;
205205 [self rollbackPackage ];
206- didRollback = YES ;
207206 } else {
208207 // Mark that we tried to initialize the new update, so that if it crashes,
209208 // we will know that we need to rollback when the app next starts.
@@ -293,7 +292,7 @@ - (void)loadBundle
293292- (void )recordDeploymentStatusReported : (NSString *)appVersionOrPackageIdentifier
294293{
295294 NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
296- [preferences setValue: LastDeploymentReportKey forKey: appVersionOrPackageIdentifier ];
295+ [preferences setValue: appVersionOrPackageIdentifier forKey: LastDeploymentReportKey ];
297296 [preferences synchronize ];
298297}
299298
@@ -534,8 +533,9 @@ - (void)savePendingUpdate:(NSString *)packageHash
534533RCT_EXPORT_METHOD (getNewStatusReport:(RCTPromiseResolveBlock)resolve
535534 rejecter:(RCTPromiseRejectBlock)reject)
536535{
537- if (didRollback ) {
536+ if (needToReportRollback ) {
538537 // Check if there was a rollback that was not yet reported
538+ needToReportRollback = NO ;
539539 NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
540540 NSMutableArray *failedUpdates = [preferences objectForKey: FailedUpdatesKey];
541541 if (failedUpdates) {
0 commit comments