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

Commit 99da36f

Browse files
committed
Merge pull request #218 from Microsoft/handle-uncleared-updates-debug
Handle uncleared updates during debug
2 parents 2141e72 + 7dd1b47 commit 99da36f

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CodePush.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ async function checkForUpdate(deploymentKey = null) {
7070
* because we want to avoid having to install diff updates against the binary's
7171
* version, which we can't do yet on Android.
7272
*/
73-
if (!update || update.updateAppVersion || localPackage && (update.packageHash === localPackage.packageHash) || !localPackage && config.packageHash === update.packageHash) {
73+
if (!update || update.updateAppVersion ||
74+
localPackage && (update.packageHash === localPackage.packageHash) ||
75+
(!localPackage || localPackage._isDebugOnly) && config.packageHash === update.packageHash) {
7476
if (update && update.updateAppVersion) {
7577
log("An update is available but it is targeting a newer binary version than you are currently running.");
7678
}

android/app/src/main/java/com/microsoft/codepush/react/CodePush.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ protected Void doInBackground(Object... params) {
423423
return null;
424424
}
425425

426+
if (isRunningBinaryVersion) {
427+
currentPackage.putBoolean("_isDebugOnly", true);
428+
}
429+
426430
Boolean isPendingUpdate = false;
427431

428432
if (currentPackage.hasKey(codePushPackage.PACKAGE_HASH_KEY)) {

ios/CodePush/CodePush.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,13 @@ - (void)savePendingUpdate:(NSString *)packageHash
480480
return;
481481
}
482482

483+
if (isRunningBinaryVersion) {
484+
// This only matters in Debug builds. Since we do not clear "outdated" updates,
485+
// we need to indicate to the JS side that somehow we have a current update on
486+
// disk that is not actually running.
487+
[package setObject:@(YES) forKey:@"_isDebugOnly"];
488+
}
489+
483490
// Add the "isPending" virtual property to the package at this point, so that
484491
// the script-side doesn't need to immediately call back into native to populate it.
485492
BOOL isPendingUpdate = [self isPendingUpdate:[package objectForKey:PackageHashKey]];

0 commit comments

Comments
 (0)