Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 380df40

Browse files
committed
Merge pull request #56 from Microsoft/sync_bugs
Bug fixes with the new sync refactor
2 parents b559ca2 + ba98734 commit 380df40

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

CodePush.ios.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var extend = require("extend");
43
var NativeCodePush = require("react-native").NativeModules.CodePush;
54
var requestFetchAdapter = require("./request-fetch-adapter.js");
65
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
@@ -103,7 +102,7 @@ function checkForUpdate() {
103102
return resolve(null);
104103
}
105104

106-
update = extend(update, packageMixins.remote);
105+
update = Object.assign(update, packageMixins.remote);
107106

108107
NativeCodePush.isFailedUpdate(update.packageHash)
109108
.then((isFailedHash) => {
@@ -210,7 +209,13 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
210209
resolve(CodePush.SyncStatus.UP_TO_DATE);
211210
}
212211
else if (syncOptions.updateDialog) {
213-
syncOptions.updateDialog = Object.assign(CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog);
212+
// updateDialog supports any truthy value (e.g. true, "goo", 12),
213+
// but we should treat a non-object value as just the default dialog
214+
if (typeof syncOptions.updateDialog !== "object") {
215+
syncOptions.updateDialog = CodePush.DEFAULT_UPDATE_DIALOG;
216+
} else {
217+
syncOptions.updateDialog = Object.assign({}, CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog);
218+
}
214219

215220
var message = null;
216221
var dialogButtons = [
@@ -233,7 +238,10 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
233238
// to allow the end-user to ignore it
234239
dialogButtons.push({
235240
text: syncOptions.updateDialog.optionalIgnoreButtonLabel,
236-
onPress: () => resolve(CodePush.SyncStatus.UPDATE_IGNORED)
241+
onPress: () => {
242+
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_IGNORED);
243+
resolve(CodePush.SyncStatus.UPDATE_IGNORED);
244+
}
237245
});
238246
}
239247

@@ -244,7 +252,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
244252
}
245253

246254
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
247-
AlertIOS.alert(syncOptions.updateTitle, message, dialogButtons);
255+
AlertIOS.alert(syncOptions.updateDialog.title, message, dialogButtons);
248256
} else {
249257
doDownloadAndInstall();
250258
}
@@ -288,8 +296,8 @@ var CodePush = {
288296
optionalIgnoreButtonLabel: "Ignore",
289297
optionalInstallButtonLabel: "Install",
290298
optionalUpdateMessage: "An update is available. Would you like to install it?",
291-
updateTitle: "Update available",
299+
title: "Update available"
292300
}
293301
};
294302

295-
module.exports = CodePush;
303+
module.exports = CodePush;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ The method accepts an options object that allows you to customize numerous aspec
200200
* __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"`.
201201
* __optionalInstallButtonLabel__ (String) - The text to use for the button the end-user can press in order to install an optional update. Defaults to `"Install"`.
202202
* __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?"`.
203-
* __updateTitle__ (String) - The text used as the header of an update notification that is displayed to the end-user. Defaults to `"Update available"`.
203+
* __title__ (String) - The text used as the header of an update notification that is displayed to the end-user. Defaults to `"Update available"`.
204204

205205
In addition, the method also recieves two function arguments which serve as event handlers which are called at various points in the sync process:
206206

package-mixins.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var extend = require("extend");
21
var { NativeAppEventEmitter } = require("react-native");
32

43
module.exports = (NativeCodePush) => {
@@ -25,7 +24,7 @@ module.exports = (NativeCodePush) => {
2524
return NativeCodePush.downloadUpdate(this)
2625
.then((downloadedPackage) => {
2726
downloadProgressSubscription && downloadProgressSubscription.remove();
28-
return extend({}, downloadedPackage, local);
27+
return Object.assign({}, downloadedPackage, local);
2928
})
3029
.catch((error) => {
3130
downloadProgressSubscription && downloadProgressSubscription.remove();

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-code-push",
3-
"version": "1.2.0-beta",
3+
"version": "1.2.1-beta",
44
"description": "React Native plugin for the CodePush service",
55
"main": "CodePush.ios.js",
66
"homepage": "https://microsoft.github.io/code-push",
@@ -16,8 +16,7 @@
1616
"url": "https://github.com/Microsoft/react-native-code-push"
1717
},
1818
"dependencies": {
19-
"code-push": "^1.1.1-beta",
20-
"extend": "3.0.0"
19+
"code-push": "^1.1.1-beta"
2120
},
2221
"devDependencies": {
2322
"react-native": "0.11.4"

0 commit comments

Comments
 (0)