Skip to content

Commit

Permalink
Allow to disable deploy updates with DisableDeploy preference (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored and nphyatt committed Sep 13, 2018
1 parent 17b5de5 commit a1664d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void init(CordovaWebView parentWebView, CordovaInterface cordova, final C
super.init(parentWebView, cordova, client, resourceApi, pluginManager, nativeToJsMessageQueue);
SharedPreferences prefs = cordova.getActivity().getApplicationContext().getSharedPreferences(IonicWebView.WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE);
String path = prefs.getString(IonicWebView.CDV_SERVER_PATH, null);
if (!isNewBinary() && path != null && !path.isEmpty()) {
if (!isDeployDisabled() && !isNewBinary() && path != null && !path.isEmpty()) {
setServerBasePath(path);
}
}
Expand Down Expand Up @@ -100,6 +100,9 @@ private boolean isNewBinary() {
return false;
}

private boolean isDeployDisabled() {
return preferences.getBoolean("DisableDeploy", false);
}
private class ServerClient extends SystemWebViewClient {
private ConfigXmlParser parser;

Expand Down
6 changes: 5 additions & 1 deletion src/ios/CDVWKWebViewEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ - (void)initWebServer

NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
NSString * persistedPath = [userDefaults objectForKey:CDV_SERVER_PATH];
if (![self isNewBinary] && persistedPath && ![persistedPath isEqualToString:@""]) {
if (![self isDeployDisabled] && ![self isNewBinary] && persistedPath && ![persistedPath isEqualToString:@""]) {
NSString *libPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString * cordovaDataDirectory = [libPath stringByAppendingPathComponent:@"NoCloud"];
NSString * snapshots = [cordovaDataDirectory stringByAppendingPathComponent:@"ionic_built_snapshots"];
Expand Down Expand Up @@ -181,6 +181,10 @@ -(BOOL) isNewBinary
return NO;
}

-(BOOL) isDeployDisabled {
return [[self.commandDelegate.settings objectForKey:[@"DisableDeploy" lowercaseString]] boolValue];
}

-(void)updateBindPath
{
NSDictionary * settings = self.commandDelegate.settings;
Expand Down

0 comments on commit a1664d8

Please sign in to comment.