mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-09 20:25:15 +08:00
Merge pull request #56 from Microsoft/sync_bugs
Bug fixes with the new sync refactor
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var extend = require("extend");
|
||||
var NativeCodePush = require("react-native").NativeModules.CodePush;
|
||||
var requestFetchAdapter = require("./request-fetch-adapter.js");
|
||||
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
|
||||
@@ -103,7 +102,7 @@ function checkForUpdate() {
|
||||
return resolve(null);
|
||||
}
|
||||
|
||||
update = extend(update, packageMixins.remote);
|
||||
update = Object.assign(update, packageMixins.remote);
|
||||
|
||||
NativeCodePush.isFailedUpdate(update.packageHash)
|
||||
.then((isFailedHash) => {
|
||||
@@ -210,7 +209,13 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
|
||||
resolve(CodePush.SyncStatus.UP_TO_DATE);
|
||||
}
|
||||
else if (syncOptions.updateDialog) {
|
||||
syncOptions.updateDialog = Object.assign(CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog);
|
||||
// updateDialog supports any truthy value (e.g. true, "goo", 12),
|
||||
// but we should treat a non-object value as just the default dialog
|
||||
if (typeof syncOptions.updateDialog !== "object") {
|
||||
syncOptions.updateDialog = CodePush.DEFAULT_UPDATE_DIALOG;
|
||||
} else {
|
||||
syncOptions.updateDialog = Object.assign({}, CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog);
|
||||
}
|
||||
|
||||
var message = null;
|
||||
var dialogButtons = [
|
||||
@@ -233,7 +238,10 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
|
||||
// to allow the end-user to ignore it
|
||||
dialogButtons.push({
|
||||
text: syncOptions.updateDialog.optionalIgnoreButtonLabel,
|
||||
onPress: () => resolve(CodePush.SyncStatus.UPDATE_IGNORED)
|
||||
onPress: () => {
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_IGNORED);
|
||||
resolve(CodePush.SyncStatus.UPDATE_IGNORED);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -244,7 +252,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
|
||||
}
|
||||
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
|
||||
AlertIOS.alert(syncOptions.updateTitle, message, dialogButtons);
|
||||
AlertIOS.alert(syncOptions.updateDialog.title, message, dialogButtons);
|
||||
} else {
|
||||
doDownloadAndInstall();
|
||||
}
|
||||
@@ -288,8 +296,8 @@ var CodePush = {
|
||||
optionalIgnoreButtonLabel: "Ignore",
|
||||
optionalInstallButtonLabel: "Install",
|
||||
optionalUpdateMessage: "An update is available. Would you like to install it?",
|
||||
updateTitle: "Update available",
|
||||
title: "Update available"
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = CodePush;
|
||||
module.exports = CodePush;
|
||||
@@ -200,7 +200,7 @@ The method accepts an options object that allows you to customize numerous aspec
|
||||
* __optionalIgnoreButtonLabel__ (String) - The text to use for the button the end-user can press in order to ignore an optional update that is available. Defaults to `"Ignore"`.
|
||||
* __optionalInstallButtonLabel__ (String) - The text to use for the button the end-user can press in order to install an optional update. Defaults to `"Install"`.
|
||||
* __optionalUpdateMessage__ (String) - The text used as the body of an update notification, when the update is optional. Defaults to `"An update is available. Would you like to install it?"`.
|
||||
* __updateTitle__ (String) - The text used as the header of an update notification that is displayed to the end-user. Defaults to `"Update available"`.
|
||||
* __title__ (String) - The text used as the header of an update notification that is displayed to the end-user. Defaults to `"Update available"`.
|
||||
|
||||
In addition, the method also recieves two function arguments which serve as event handlers which are called at various points in the sync process:
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
var extend = require("extend");
|
||||
var { NativeAppEventEmitter } = require("react-native");
|
||||
|
||||
module.exports = (NativeCodePush) => {
|
||||
@@ -25,7 +24,7 @@ module.exports = (NativeCodePush) => {
|
||||
return NativeCodePush.downloadUpdate(this)
|
||||
.then((downloadedPackage) => {
|
||||
downloadProgressSubscription && downloadProgressSubscription.remove();
|
||||
return extend({}, downloadedPackage, local);
|
||||
return Object.assign({}, downloadedPackage, local);
|
||||
})
|
||||
.catch((error) => {
|
||||
downloadProgressSubscription && downloadProgressSubscription.remove();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-code-push",
|
||||
"version": "1.2.0-beta",
|
||||
"version": "1.2.1-beta",
|
||||
"description": "React Native plugin for the CodePush service",
|
||||
"main": "CodePush.ios.js",
|
||||
"homepage": "https://microsoft.github.io/code-push",
|
||||
@@ -16,8 +16,7 @@
|
||||
"url": "https://github.com/Microsoft/react-native-code-push"
|
||||
},
|
||||
"dependencies": {
|
||||
"code-push": "^1.1.1-beta",
|
||||
"extend": "3.0.0"
|
||||
"code-push": "^1.1.1-beta"
|
||||
},
|
||||
"devDependencies": {
|
||||
"react-native": "0.11.4"
|
||||
|
||||
Reference in New Issue
Block a user