Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request microsoft#56 from Microsoft/sync_bugs
Browse files Browse the repository at this point in the history
Bug fixes with the new sync refactor
  • Loading branch information
lostintangent committed Nov 20, 2015
2 parents b559ca2 + ba98734 commit 380df40
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
22 changes: 15 additions & 7 deletions CodePush.ios.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 = [
Expand All @@ -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);
}
});
}

Expand All @@ -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();
}
Expand Down Expand Up @@ -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;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 1 addition & 2 deletions package-mixins.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var extend = require("extend");
var { NativeAppEventEmitter } = require("react-native");

module.exports = (NativeCodePush) => {
Expand All @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
Expand Down

0 comments on commit 380df40

Please sign in to comment.