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

Commit e02c06a

Browse files
committed
Bug fixes
1 parent b559ca2 commit e02c06a

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

CodePush.ios.js

Lines changed: 16 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,14 @@ 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 when we merge it's properties with the default dialog's
214+
// properties, it needs to be an object
215+
if (typeof syncOptions.updateDialog !== "object") {
216+
syncOptions.updateDialog = CodePush.DEFAULT_UPDATE_DIALOG;
217+
} else {
218+
syncOptions.updateDialog = Object.assign(CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog);
219+
}
214220

215221
var message = null;
216222
var dialogButtons = [
@@ -233,7 +239,10 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
233239
// to allow the end-user to ignore it
234240
dialogButtons.push({
235241
text: syncOptions.updateDialog.optionalIgnoreButtonLabel,
236-
onPress: () => resolve(CodePush.SyncStatus.UPDATE_IGNORED)
242+
onPress: () => {
243+
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_IGNORED);
244+
resolve(CodePush.SyncStatus.UPDATE_IGNORED);
245+
}
237246
});
238247
}
239248

@@ -244,7 +253,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
244253
}
245254

246255
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
247-
AlertIOS.alert(syncOptions.updateTitle, message, dialogButtons);
256+
AlertIOS.alert(syncOptions.updateDialog.title, message, dialogButtons);
248257
} else {
249258
doDownloadAndInstall();
250259
}
@@ -288,8 +297,8 @@ var CodePush = {
288297
optionalIgnoreButtonLabel: "Ignore",
289298
optionalInstallButtonLabel: "Install",
290299
optionalUpdateMessage: "An update is available. Would you like to install it?",
291-
updateTitle: "Update available",
300+
title: "Update available"
292301
}
293302
};
294303

295-
module.exports = CodePush;
304+
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

0 commit comments

Comments
 (0)