Tweaking log messages

This commit is contained in:
Jonathan Carter
2016-05-23 17:30:52 -07:00
parent 60f8c8bb35
commit 1306c4b635
2 changed files with 36 additions and 27 deletions

View File

@@ -182,15 +182,23 @@ async function tryReportStatus(resumeListener) {
const previousDeploymentKey = statusReport.previousDeploymentKey || config.deploymentKey;
try {
if (statusReport.appVersion) {
log(`Reporting binary update (${statusReport.appVersion})`);
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
await sdk.reportStatusDeploy(/* deployedPackage */ null, /* status */ null, previousLabelOrAppVersion, previousDeploymentKey);
} else {
const label = statusReport.package.label;
if (statusReport.status === "DeploymentSucceeded") {
log(`Reporting CodePush update success (${label})`);
} else {
log(`Reporting CodePush update rollback (${label})`);
}
config.deploymentKey = statusReport.package.deploymentKey;
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
await sdk.reportStatusDeploy(statusReport.package, statusReport.status, previousLabelOrAppVersion, previousDeploymentKey);
}
log(`Reported status: ${JSON.stringify(statusReport)}`);
NativeCodePush.recordStatusReported(statusReport);
resumeListener && AppState.removeEventListener("change", resumeListener);
} catch (e) {

View File

@@ -1,45 +1,46 @@
let log = require('./logging');
let NativeCodePush = require("react-native").NativeModules.CodePush;
const log = require("./logging");
const NativeCodePush = require("react-native").NativeModules.CodePush;
const RestartManager = (() => {
let _allowed = true;
let _restartPending = false;
function allow() {
log("Re-allowing restarts");
_allowed = true;
if (_restartPending) {
log("Executing pending restart");
restartApp(true);
}
}
function clearPendingRestart() {
_restartPending = false;
}
function disallow() {
log("Disallowing restarts");
_allowed = false;
}
function restartApp(onlyIfUpdateIsPending = false) {
if (_allowed) {
NativeCodePush.restartApp(onlyIfUpdateIsPending);
log('restaes');
log("Restarting app");
} else {
log("restart not allowed");
log("Restart request queued until restarts are re-allowed");
_restartPending = true;
return true;
}
}
function allow() {
log("allow restart");
_allowed = true;
if (_restartPending) {
log("executing pending restart");
restartApp(true);
}
}
function disallow() {
log("disallow restart");
_allowed = false;
}
function clearPendingRestart() {
_restartPending = false;
}
return {
allow,
clearPendingRestart,
disallow,
restartApp,
clearPendingRestart
restartApp
};
})();
module.exports = RestartManager;
module.exports = RestartManager;