mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
Tweaking log messages
This commit is contained in:
12
CodePush.js
12
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) {
|
||||
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user