Merge pull request #131 from Microsoft/restart_bug

Fixing immediate restart
This commit is contained in:
Jonathan Carter
2015-12-28 11:38:04 -08:00
3 changed files with 7 additions and 10 deletions

View File

@@ -1,5 +1,3 @@
"use strict";
import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
import { Alert } from "./AlertAdapter";
import requestFetchAdapter from "./request-fetch-adapter";
@@ -19,6 +17,7 @@ async function checkForUpdate(deploymentKey = null) {
* different from the CodePush update they have already installed.
*/
const nativeConfig = await getConfiguration();
/*
* If a deployment key was explicitly provided,
* then let's override the one we retrieved
@@ -26,11 +25,12 @@ async function checkForUpdate(deploymentKey = null) {
* dynamically "redirecting" end-users at different
* deployments (e.g. an early access deployment for insiders).
*/
const config = deploymentKey ? { ...nativeConfig, ...{ deploymentKey } }
: nativeConfig;
const config = deploymentKey ? { ...nativeConfig, ...{ deploymentKey } } : nativeConfig;
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
// Use dynamically overridden getCurrentPackage() during tests.
const localPackage = await module.exports.getCurrentPackage();
/*
* If the app has a previously installed update, and that update
* was targetted at the same app version that is currently running,
@@ -43,6 +43,7 @@ async function checkForUpdate(deploymentKey = null) {
? localPackage
: { appVersion: config.appVersion };
const update = await sdk.queryUpdateWithCurrentPackage(queryPackage);
/*
* There are three cases where checkForUpdate will resolve to null:
* ----------------------------------------------------------------

View File

@@ -1,5 +1,3 @@
"use strict";
import { DeviceEventEmitter } from "react-native";
// This function is used to augment remote and local
@@ -40,7 +38,7 @@ module.exports = (NativeCodePush) => {
await NativeCodePush.installUpdate(this, installMode);
updateInstalledCallback && updateInstalledCallback();
if (installMode == NativeCodePush.codePushInstallModeImmediate) {
NativeCodePush.restartApp();
NativeCodePush.restartApp(false);
} else {
localPackage.isPending = true; // Mark the package as pending since it hasn't been applied yet
}

View File

@@ -1,5 +1,3 @@
"use strict";
module.exports = {
async request(verb, url, body, callback) {
if (typeof body === "function") {
@@ -30,4 +28,4 @@ module.exports = {
callback(err);
}
}
};
};