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

Commit d8e6d30

Browse files
committed
move restartApp to RestartManager
1 parent d09baad commit d8e6d30

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

CodePush.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,6 @@ async function tryReportStatus(resumeListener) {
214214
}
215215
}
216216

217-
function restartApp(onlyIfUpdateIsPending = false) {
218-
NativeCodePush.restartApp(onlyIfUpdateIsPending);
219-
}
220-
221217
var testConfig;
222218

223219
// This function is only used for tests. Replaces the default SDK, configuration and native bridge
@@ -410,7 +406,7 @@ if (NativeCodePush) {
410406
log,
411407
notifyAppReady: notifyApplicationReady,
412408
notifyApplicationReady,
413-
restartApp,
409+
restartApp: RestartManager.restartApp,
414410
setUpTestDependencies,
415411
sync,
416412
disallowRestart: RestartManager.disallow,
@@ -420,7 +416,6 @@ if (NativeCodePush) {
420416
IMMEDIATE: NativeCodePush.codePushInstallModeImmediate, // Restart the app immediately
421417
ON_NEXT_RESTART: NativeCodePush.codePushInstallModeOnNextRestart, // Don't artificially restart the app. Allow the update to be "picked up" on the next app restart
422418
ON_NEXT_RESUME: NativeCodePush.codePushInstallModeOnNextResume, // Restart the app the next time it is resumed from the background
423-
ON_NEXT_RESTART_OPPORTUNITY: NativeCodePush.codePushInstallModeOnNextRestartOpportunity
424419
},
425420
SyncStatus: {
426421
CHECKING_FOR_UPDATE: 0,

RestartManager.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,16 @@ let NativeCodePush = require("react-native").NativeModules.CodePush;
22

33
const RestartManager = (() => {
44
let _allowed = true;
5-
let restartPending = false;
65

7-
function tryRestart() {
8-
if (restartPending && _allowed == true) {
9-
NativeCodePush.restartApp(true);
6+
function restartApp(onlyIfUpdateIsPending = false) {
7+
if (_allowed) {
8+
NativeCodePush.restartApp(onlyIfUpdateIsPending);
109
}
1110
}
1211

13-
function requestRestart() {
14-
restartPending = true;
15-
tryRestart();
16-
}
17-
1812
function allow() {
1913
_allowed = true;
20-
tryRestart();
14+
restartApp(true);
2115
}
2216

2317
function allowed() {
@@ -32,7 +26,7 @@ const RestartManager = (() => {
3226
allow,
3327
disallow,
3428
allowed,
35-
requestRestart
29+
restartApp,
3630
};
3731
})();
3832

package-mixins.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ module.exports = (NativeCodePush) => {
4343
await NativeCodePush.installUpdate(this, installMode, minimumBackgroundDuration);
4444
updateInstalledCallback && updateInstalledCallback();
4545
if (installMode == NativeCodePush.codePushInstallModeImmediate) {
46-
NativeCodePush.restartApp(false);
46+
RestartManager.restartApp(false);
4747
} else {
48-
if (installMode == NativeCodePush.codePushInstallModeOnNextRestartOpportunity) {
49-
RestartManager.requestRestart();
50-
}
5148
localPackage.isPending = true; // Mark the package as pending since it hasn't been applied yet
5249
}
5350
},

0 commit comments

Comments
 (0)