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

Commit c843375

Browse files
CodePush.js: fix syncStatus value mismatch (#765)
After `SyncStatus` correctly goes to `UPDATE_INSTALLED`, on the next resume it transitions to `CHECKING_FOR_UPDATE` and then `UP_TO_DATE`, even though the update has not yet been installed. It should be equals to `UPDATE_INSTALLED` value again until next app restart.
1 parent 300a835 commit c843375

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CodePush.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,14 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
342342
log("An update is available, but it is being ignored due to having been previously rolled back.");
343343
}
344344

345-
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE);
346-
return CodePush.SyncStatus.UP_TO_DATE;
345+
const currentPackage = await CodePush.getCurrentPackage();
346+
if (currentPackage.isPending) {
347+
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_INSTALLED);
348+
return CodePush.SyncStatus.UPDATE_INSTALLED;
349+
} else {
350+
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE);
351+
return CodePush.SyncStatus.UP_TO_DATE;
352+
}
347353
} else if (syncOptions.updateDialog) {
348354
// updateDialog supports any truthy value (e.g. true, "goo", 12),
349355
// but we should treat a non-object value as just the default dialog

0 commit comments

Comments
 (0)