From e02c06ac05f2c78071602736fe91f004e82ea407 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Thu, 19 Nov 2015 15:40:31 -0800 Subject: [PATCH 1/5] Bug fixes --- CodePush.ios.js | 23 ++++++++++++++++------- README.md | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CodePush.ios.js b/CodePush.ios.js index e459f13..c3a4a08 100644 --- a/CodePush.ios.js +++ b/CodePush.ios.js @@ -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,14 @@ 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 when we merge it's properties with the default dialog's + // properties, it needs to be an object + 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 +239,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 +253,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 +297,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; \ No newline at end of file diff --git a/README.md b/README.md index 08c1dad..5948d8b 100644 --- a/README.md +++ b/README.md @@ -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: From ca965f4cf91306c43878f5a6b4275932b1c14839 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Thu, 19 Nov 2015 15:46:00 -0800 Subject: [PATCH 2/5] Comment change --- CodePush.ios.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CodePush.ios.js b/CodePush.ios.js index c3a4a08..4258917 100644 --- a/CodePush.ios.js +++ b/CodePush.ios.js @@ -210,8 +210,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) } else if (syncOptions.updateDialog) { // updateDialog supports any truthy value (e.g. true, "goo", 12), - // but when we merge it's properties with the default dialog's - // properties, it needs to be an object + // 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 { From dd73ab0f8bc70a6a0709e2c009a10c518396b868 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Thu, 19 Nov 2015 16:18:14 -0800 Subject: [PATCH 3/5] Assign fix --- CodePush.ios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodePush.ios.js b/CodePush.ios.js index 4258917..2c5d547 100644 --- a/CodePush.ios.js +++ b/CodePush.ios.js @@ -214,7 +214,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) if (typeof syncOptions.updateDialog !== "object") { syncOptions.updateDialog = CodePush.DEFAULT_UPDATE_DIALOG; } else { - syncOptions.updateDialog = Object.assign(CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog); + syncOptions.updateDialog = Object.assign({}, CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog); } var message = null; From 5898261c6d0c2ee2e2828e2a5fde55adcf998b0e Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Thu, 19 Nov 2015 16:22:21 -0800 Subject: [PATCH 4/5] Removing second use of extend --- package-mixins.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package-mixins.js b/package-mixins.js index a098c15..aa0f3de 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -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(); From ba98734f781a3d0b14eb496fd45c9c0d98ffb751 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Thu, 19 Nov 2015 16:26:54 -0800 Subject: [PATCH 5/5] Removing extend and bumping version --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4f874e5..46ac764 100644 --- a/package.json +++ b/package.json @@ -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"