From 340bb7e74a67938e58dafc9a2d1478949562e1d3 Mon Sep 17 00:00:00 2001 From: Geoffrey Goh Date: Fri, 5 Feb 2016 22:59:54 -0800 Subject: [PATCH] feedback --- CodePush.js | 8 ++++---- CodePush.m | 2 ++ .../main/java/com/microsoft/codepush/react/CodePush.java | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CodePush.js b/CodePush.js index e3c726d..0f2c05f 100644 --- a/CodePush.js +++ b/CodePush.js @@ -170,20 +170,20 @@ function setUpTestDependencies(testSdk, providedTestConfig, testNativeBridge) { if (testNativeBridge) NativeCodePush = testNativeBridge; } -// This function allows sync operations to be chained on to each other so that they do not +// This function allows calls to syncInternal to be chained on to each other so that they do not // interleave in the event that sync() is called multiple times. const sync = (() => { let syncPromiseChain = Promise.resolve(); return (options = {}, syncStatusChangeCallback, downloadProgressCallback) => { syncPromiseChain = syncPromiseChain .catch(() => {}) - .then(() => syncOperation(options, syncStatusChangeCallback, downloadProgressCallback)); + .then(() => syncInternal(options, syncStatusChangeCallback, downloadProgressCallback)); return syncPromiseChain; }; })(); /* - * The syncOperation method provides a simple, one-line experience for + * The syncInternal method provides a simple, one-line experience for * incorporating the check, download and application of an update. * * It simply composes the existing API methods together and adds additional @@ -191,7 +191,7 @@ const sync = (() => { * releases, and displaying a standard confirmation UI to the end-user * when an update is available. */ -async function syncOperation(options = {}, syncStatusChangeCallback, downloadProgressCallback) { +async function syncInternal(options = {}, syncStatusChangeCallback, downloadProgressCallback) { const syncOptions = { deploymentKey: null, diff --git a/CodePush.m b/CodePush.m index 216c7a8..7be8e53 100644 --- a/CodePush.m +++ b/CodePush.m @@ -506,6 +506,8 @@ RCT_EXPORT_METHOD(isFirstRun:(NSString *)packageHash RCT_EXPORT_METHOD(notifyApplicationReady:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + // We only mark a pending update as succeeded only if it update has been booted up, + // during which `_isFirstRunAfterUpdate` is true. if (_isFirstRunAfterUpdate) { [CodePush removePendingUpdate]; } diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index 4825d3b..aad6a00 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -539,10 +539,12 @@ public class CodePush { @ReactMethod public void notifyApplicationReady(Promise promise) { + // We only mark a pending update as succeeded only if it update has been booted up, + // during which `didUpdate` is true. if (didUpdate) { removePendingUpdate(); } - + promise.resolve(""); }