Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 4326515

Browse files
committed
CR feedback
1 parent 67f211a commit 4326515

File tree

3 files changed

+174
-162
lines changed

3 files changed

+174
-162
lines changed

CodePush.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,18 @@ function codePushify(options = {}) {
423423

424424
return class CodePushComponent extends React.Component {
425425
componentDidMount() {
426-
let rootComponentInstance = this.refs.rootComponent;
427-
let syncStatusCallback = rootComponentInstance && rootComponentInstance.codePushStatusDidChange;
428-
let downloadProgressCallback = rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress;
429-
CodePush.sync(options, syncStatusCallback, downloadProgressCallback)
430-
if (options.syncMode === CodePush.SyncMode.ON_APP_RESUME) {
431-
ReactNative.AppState.addEventListener("change", (newState) => {
432-
newState === "active" && CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
433-
});
426+
if (options.checkFrequency === CodePush.CheckFrequency.MANUAL) {
427+
CodePush.notifyAppReady();
428+
} else {
429+
let rootComponentInstance = this.refs.rootComponent;
430+
let syncStatusCallback = rootComponentInstance && rootComponentInstance.codePushStatusDidChange;
431+
let downloadProgressCallback = rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress;
432+
CodePush.sync(options, syncStatusCallback, downloadProgressCallback)
433+
if (options.checkFrequency === CodePush.CheckFrequency.ON_APP_RESUME) {
434+
ReactNative.AppState.addEventListener("change", (newState) => {
435+
newState === "active" && CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
436+
});
437+
}
434438
}
435439
}
436440

@@ -446,7 +450,8 @@ function codePushify(options = {}) {
446450
// and therefore, it doesn't make sense initializing
447451
// the JS interface when it wouldn't work anyways.
448452
if (NativeCodePush) {
449-
CodePush = {
453+
CodePush = codePushify;
454+
Object.assign(CodePush, {
450455
AcquisitionSdk: Sdk,
451456
checkForUpdate,
452457
codePushify,
@@ -477,9 +482,10 @@ if (NativeCodePush) {
477482
DOWNLOADING_PACKAGE: 7,
478483
INSTALLING_UPDATE: 8
479484
},
480-
SyncMode: {
485+
CheckFrequency: {
481486
ON_APP_START: 0,
482487
ON_APP_RESUME: 1,
488+
MANUAL: 2
483489
},
484490
UpdateState: {
485491
RUNNING: NativeCodePush.codePushUpdateStateRunning,
@@ -500,7 +506,7 @@ if (NativeCodePush) {
500506
optionalUpdateMessage: "An update is available. Would you like to install it?",
501507
title: "Update available"
502508
}
503-
};
509+
});
504510
} else {
505511
log("The CodePush module doesn't appear to be properly installed. Please double-check that everything is setup correctly.");
506512
}

0 commit comments

Comments
 (0)