Skip to content

Commit

Permalink
[expo-updates][android][ios] allow reloading in dev mode in store cli…
Browse files Browse the repository at this point in the history
…ents (expo#10310)
  • Loading branch information
esamelson authored Sep 24, 2020
1 parent 8da7486 commit 7e43e88
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public boolean isUsingEmbeddedAssets() {
return false;
}

@Override
public boolean canRelaunch() {
return true;
}

@Override
public UpdateEntity getLaunchedUpdate() {
return mAppLoader.getLauncher().getLaunchedUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface UpdatesInterface {

boolean isEmergencyLaunch();
boolean isUsingEmbeddedAssets();
boolean canRelaunch();
UpdateEntity getLaunchedUpdate();
Map<AssetEntity, String> getLocalAssetFiles();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Map<String, Object> getConstants() {
public void reload(final Promise promise) {
try {
UpdatesInterface updatesService = getUpdatesService();
if (!updatesService.getConfiguration().isEnabled()) {
if (!updatesService.canRelaunch()) {
promise.reject("ERR_UPDATES_DISABLED", "You cannot reload when expo-updates is not enabled.");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public boolean isUsingEmbeddedAssets() {
return UpdatesController.getInstance().isUsingEmbeddedAssets();
}

@Override
public boolean canRelaunch() {
return getConfiguration().isEnabled();
}

@Override
public UpdateEntity getLaunchedUpdate() {
return UpdatesController.getInstance().getLaunchedUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public boolean isUsingEmbeddedAssets() {
return false;
}

@Override
public boolean canRelaunch() {
return true;
}

@Override
public UpdateEntity getLaunchedUpdate() {
return mAppLoader.getLauncher().getLaunchedUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ - (BOOL)isEmergencyLaunch
return [_updatesKernelService isEmergencyLaunchForExperienceId:_experienceId];
}

- (BOOL)canRelaunch
{
return YES;
}

- (void)requestRelaunchWithCompletion:(EXUpdatesAppRelaunchCompletionBlock)completion
{
return [_updatesKernelService requestRelaunchForExperienceId:_experienceId withCompletion:completion];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (NSDictionary *)constantsToExport
reloadAsync:(ABI39_0_0UMPromiseResolveBlock)resolve
reject:(ABI39_0_0UMPromiseRejectBlock)reject)
{
if (!_updatesService.isStarted) {
if (!_updatesService.canRelaunch) {
reject(@"ERR_UPDATES_DISABLED", @"The updates module controller has not been properly initialized. If you're in development mode, you cannot use this method. Otherwise, make sure you have called [[ABI39_0_0EXUpdatesAppController sharedInstance] start].", nil);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef void (^ABI39_0_0EXUpdatesAppRelaunchCompletionBlock)(BOOL success);
@property (nonatomic, readonly, assign) BOOL isUsingEmbeddedAssets;
@property (nonatomic, readonly, assign) BOOL isStarted;
@property (nonatomic, readonly, assign) BOOL isEmergencyLaunch;
@property (nonatomic, readonly, assign) BOOL canRelaunch;

- (void)requestRelaunchWithCompletion:(ABI39_0_0EXUpdatesAppRelaunchCompletionBlock)completion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ - (BOOL)isEmergencyLaunch
return ABI39_0_0EXUpdatesAppController.sharedInstance.isEmergencyLaunch;
}

- (BOOL)canRelaunch
{
return ABI39_0_0EXUpdatesAppController.sharedInstance.isStarted;
}

- (void)requestRelaunchWithCompletion:(ABI39_0_0EXUpdatesAppRelaunchCompletionBlock)completion
{
return [ABI39_0_0EXUpdatesAppController.sharedInstance requestRelaunchWithCompletion:completion];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ - (BOOL)isEmergencyLaunch
return [_updatesKernelService isEmergencyLaunchForExperienceId:_experienceId];
}

- (BOOL)canRelaunch
{
return YES;
}

- (void)requestRelaunchWithCompletion:(ABI39_0_0EXUpdatesAppRelaunchCompletionBlock)completion
{
return [_updatesKernelService requestRelaunchForExperienceId:_experienceId withCompletion:completion];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface UpdatesInterface {

boolean isEmergencyLaunch();
boolean isUsingEmbeddedAssets();
boolean canRelaunch();
UpdateEntity getLaunchedUpdate();
Map<AssetEntity, String> getLocalAssetFiles();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Map<String, Object> getConstants() {
public void reload(final Promise promise) {
try {
UpdatesInterface updatesService = getUpdatesService();
if (!updatesService.getConfiguration().isEnabled()) {
if (!updatesService.canRelaunch()) {
promise.reject("ERR_UPDATES_DISABLED", "You cannot reload when expo-updates is not enabled.");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public boolean isUsingEmbeddedAssets() {
return UpdatesController.getInstance().isUsingEmbeddedAssets();
}

@Override
public boolean canRelaunch() {
return getConfiguration().isEnabled();
}

@Override
public UpdateEntity getLaunchedUpdate() {
return UpdatesController.getInstance().getLaunchedUpdate();
Expand Down
4 changes: 2 additions & 2 deletions packages/expo-updates/build/Updates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-updates/build/Updates.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7e43e88

Please sign in to comment.