diff --git a/CodePush.js b/CodePush.js index 4804063..253e1c9 100644 --- a/CodePush.js +++ b/CodePush.js @@ -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) { diff --git a/RestartManager.js b/RestartManager.js index 0b33c7e..a34fffe 100644 --- a/RestartManager.js +++ b/RestartManager.js @@ -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; \ No newline at end of file