mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-13 09:25:36 +08:00
conforming to coding guidelines 2
This commit is contained in:
@@ -22,9 +22,9 @@ var HybridMobileDeployCompanion = React.createClass({
|
||||
this.fetchData();
|
||||
},
|
||||
fetchData: function() {
|
||||
HybridMobileDeploy.queryUpdate((err, update) => {
|
||||
this.setState({ update: update, updateString: JSON.stringify(update) });
|
||||
});
|
||||
HybridMobileDeploy.queryUpdate((err, update) => {
|
||||
this.setState({ update: update, updateString: JSON.stringify(update) });
|
||||
});
|
||||
},
|
||||
getInitialState: function() {
|
||||
return { update: false, updateString: "" };
|
||||
|
||||
@@ -45,15 +45,18 @@ function queryUpdate(callback) {
|
||||
getSdk(function(err, sdk) {
|
||||
if (err) callback(err);
|
||||
NativeHybridMobileDeploy.getLocalPackage(function(err, localPackage) {
|
||||
var defaultPackage = {appVersion: configuration.appVersion};
|
||||
if (err) {
|
||||
console.log(err);
|
||||
var pkg = {appVersion: configuration.appVersion};
|
||||
sdk.queryUpdateWithCurrentPackage(pkg, callback);
|
||||
sdk.queryUpdateWithCurrentPackage(defaultPackage, callback);
|
||||
} else if (localPackage == null) {
|
||||
var pkg = {appVersion: configuration.appVersion};
|
||||
sdk.queryUpdateWithCurrentPackage(pkg, callback);
|
||||
sdk.queryUpdateWithCurrentPackage(defaultPackage, callback);
|
||||
} else {
|
||||
sdk.queryUpdateWithCurrentPackage(localPackage, callback);
|
||||
if (localPackage.appVersion !== configuration.appVersion) {
|
||||
sdk.queryUpdateWithCurrentPackage(defaultPackage, callback)
|
||||
} else {
|
||||
sdk.queryUpdateWithCurrentPackage(localPackage, callback);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -61,7 +64,7 @@ function queryUpdate(callback) {
|
||||
}
|
||||
|
||||
function installUpdate(update) {
|
||||
// use the downloaded package info. native code will save the package info
|
||||
// Use the downloaded package info. Native code will save the package info
|
||||
// so that the client knows what the current package version is.
|
||||
NativeHybridMobileDeploy.installUpdate(update, JSON.stringify(update), (err) => console.log(err));
|
||||
}
|
||||
|
||||
@@ -87,7 +87,6 @@ RCT_EXPORT_METHOD(installUpdate:(NSDictionary*)updatePackage
|
||||
NSString *updateContents = [[NSString alloc] initWithContentsOfURL:url
|
||||
encoding:NSUTF8StringEncoding
|
||||
error:&err];
|
||||
|
||||
if (err) {
|
||||
// TODO send download url
|
||||
callback(@[RCTMakeError(@"Error downloading url", err, [[NSDictionary alloc] initWithObjectsAndKeys:[url absoluteString],@"updateUrl", nil])]);
|
||||
@@ -139,7 +138,6 @@ RCT_EXPORT_METHOD(getLocalPackage: (RCTResponseSenderBlock)callback)
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
NSError* readError;
|
||||
|
||||
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&readError];
|
||||
if (readError) {
|
||||
callback(@[RCTMakeError(@"Error finding local package ", readError, [[NSDictionary alloc] initWithObjectsAndKeys:path,@"packagePath", nil]), [NSNull null]]);
|
||||
@@ -155,7 +153,6 @@ RCT_EXPORT_METHOD(getLocalPackage: (RCTResponseSenderBlock)callback)
|
||||
callback(@[[NSNull null], json]);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user