From 1725699409bac0a2eb16c5a2ba0924ebfcab5b8a Mon Sep 17 00:00:00 2001 From: LvBingru Date: Mon, 27 Jun 2016 21:15:32 +0800 Subject: [PATCH] isRolledBack bug fixed --- ios/RCTHotUpdate/RCTHotUpdate.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/RCTHotUpdate/RCTHotUpdate.m b/ios/RCTHotUpdate/RCTHotUpdate.m index fd41e96..c61a646 100644 --- a/ios/RCTHotUpdate/RCTHotUpdate.m +++ b/ios/RCTHotUpdate/RCTHotUpdate.m @@ -20,7 +20,7 @@ static NSString *const paramLastVersion = @"lastVersion"; static NSString *const paramCurrentVersion = @"currentVersion"; static NSString *const paramIsFirstTime = @"isFirstTime"; static NSString *const paramIsFirstLoadOk = @"isFirstLoadOK"; -static NSString *const keyFirstLoadLoadMarked = @"REACTNATIVECN_HOTUPDATE_FIRSTLOADMARKED_KEY"; +static NSString *const keyFirstLoadMarked = @"REACTNATIVECN_HOTUPDATE_FIRSTLOADMARKED_KEY"; static NSString *const keyRolledBackMarked = @"REACTNATIVECN_HOTUPDATE_ROLLEDBACKMARKED_KEY"; static NSString *const KeyPackageUpdatedMarked = @"REACTNATIVECN_HOTUPDATE_ISPACKAGEUPDATEDMARKED_KEY"; @@ -85,7 +85,7 @@ RCT_EXPORT_MODULE(RCTHotUpdate); BOOL isFirstLoadOK = [updateInfo[paramIsFirstLoadOk] boolValue]; NSString *loadVersioin = curVersion; - BOOL needRollback = (isFirstTime == NO && isFirstLoadOK == NO) || (loadVersioin.length<=0 && lastVersion.length>0); + BOOL needRollback = (isFirstTime == NO && isFirstLoadOK == NO) || loadVersioin.length<=0; if (needRollback) { loadVersioin = lastVersion; @@ -109,7 +109,7 @@ RCT_EXPORT_MODULE(RCTHotUpdate); NSMutableDictionary *newInfo = [[NSMutableDictionary alloc] initWithDictionary:updateInfo]; newInfo[paramIsFirstTime] = @(NO); [defaults setObject:newInfo forKey:keyUpdateInfo]; - [defaults setObject:@(YES) forKey:keyFirstLoadLoadMarked]; + [defaults setObject:@(YES) forKey:keyFirstLoadMarked]; [defaults synchronize]; } @@ -136,13 +136,13 @@ RCT_EXPORT_MODULE(RCTHotUpdate); ret[@"downloadRootDir"] = [RCTHotUpdate downloadDir]; ret[@"packageVersion"] = [RCTHotUpdate packageVersion]; ret[@"isRolledBack"] = [defaults objectForKey:keyRolledBackMarked]; - ret[@"isFirstTime"] = [defaults objectForKey:keyFirstLoadLoadMarked]; + ret[@"isFirstTime"] = [defaults objectForKey:keyFirstLoadMarked]; NSDictionary *updateInfo = [defaults dictionaryForKey:keyUpdateInfo]; ret[@"currentVersion"] = [updateInfo objectForKey:paramCurrentVersion]; - // clear isFirstTime - if ([[defaults objectForKey:keyFirstLoadLoadMarked] boolValue]) { - [defaults setObject:nil forKey:keyFirstLoadLoadMarked]; + // clear isFirstTimemarked + if ([[defaults objectForKey:keyFirstLoadMarked] boolValue]) { + [defaults setObject:nil forKey:keyFirstLoadMarked]; } // clear rolledbackmark