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

Commit d57278b

Browse files
author
scottbommarito
committed
set _inProgress back to false if a restart will not happen because there is no pending package
1 parent 46bd770 commit d57278b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

RestartManager.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const log = require("./logging");
22
const NativeCodePush = require("react-native").NativeModules.CodePush;
3+
const CodePush = require("./CodePush");
34

45
const RestartManager = (() => {
5-
let _in_progress = false;
6+
let _inProgress = false;
67
let _allowed = true;
78
let _restartPending = false;
89

@@ -26,12 +27,13 @@ const RestartManager = (() => {
2627
}
2728

2829
function restartApp(onlyIfUpdateIsPending = false) {
29-
if (_in_progress) {
30-
log("A restart request is already in progress or queued");
31-
return;
32-
}
33-
_in_progress = true;
3430
if (_allowed) {
31+
if (_inProgress) {
32+
log("A restart request is already in progress or queued");
33+
return;
34+
}
35+
// The restart won't execute if `onlyIfUpdateIsPending === true` and there is no pending update.
36+
_inProgress = !onlyIfUpdateIsPending || !!(NativeCodePush.getUpdateMetadata(CodePush.UpdateState.PENDING));
3537
NativeCodePush.restartApp(onlyIfUpdateIsPending);
3638
log("Restarting app");
3739
} else {

0 commit comments

Comments
 (0)