summaryrefslogtreecommitdiffhomepage
path: root/app/containers
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-11-09 09:03:45 +0100
committerErik Larkö <erik@mullvad.net>2017-11-09 09:03:45 +0100
commit7f6c8398eacb5421b51c1f02befde4e4f6402fc7 (patch)
tree93456d22efbf668e39147ffb50b3beee37272a8c /app/containers
parenta77e01a50b165fd8d6e2db96652a1fcc9a220723 (diff)
downloadmullvadvpn-7f6c8398eacb5421b51c1f02befde4e4f6402fc7.tar.xz
mullvadvpn-7f6c8398eacb5421b51c1f02befde4e4f6402fc7.zip
Redid the settings state and inlined a few components
Diffstat (limited to 'app/containers')
-rw-r--r--app/containers/AdvancedSettingsPage.js20
-rw-r--r--app/containers/SelectLocationPage.js4
2 files changed, 15 insertions, 9 deletions
diff --git a/app/containers/AdvancedSettingsPage.js b/app/containers/AdvancedSettingsPage.js
index 22dbdf8ec1..ecb78eb218 100644
--- a/app/containers/AdvancedSettingsPage.js
+++ b/app/containers/AdvancedSettingsPage.js
@@ -5,17 +5,18 @@ import settingsActions from '../redux/settings/actions';
import log from 'electron-log';
const mapStateToProps = (state) => {
+ const contraints = state.settings.relayConstraints;
return {
- protocol: tryOrElse( () => state.settings.relayConstraints.tunnel.openvpn.protocol.only, 'Automatic'),
- port: tryOrElse( () => state.settings.relayConstraints.tunnel.openvpn.port.only, 'Automatic'),
+ protocol: anyToAuto(contraints.protocol),
+ port: anyToAuto(contraints.port),
};
};
-function tryOrElse(toTry, orElse) {
- try {
- return toTry() || orElse;
- } catch (e) {
- return orElse;
+function anyToAuto(constraint) {
+ if (constraint === 'any') {
+ return 'Automatic';
+ } else {
+ return constraint;
}
}
@@ -42,7 +43,10 @@ const mapDispatchToProps = (dispatch, props) => {
};
backend.updateRelayConstraints(update)
- .then( () => dispatch(settingsActions.updateRelay(update)))
+ .then( () => dispatch(settingsActions.updateRelay({
+ port: typeof(portConstraint) === 'object' ? portConstraint.only : portConstraint,
+ protocol: typeof(protConstraint) === 'object' ? protConstraint.only : protConstraint,
+ })))
.catch( e => log.error('Failed updating relay constraints', e.message));
},
};
diff --git a/app/containers/SelectLocationPage.js b/app/containers/SelectLocationPage.js
index 9e5551130c..7ca2f1eb0a 100644
--- a/app/containers/SelectLocationPage.js
+++ b/app/containers/SelectLocationPage.js
@@ -22,7 +22,9 @@ const mapDispatchToProps = (dispatch, props) => {
};
backend.updateRelayConstraints(update)
- .then( () => dispatch(settingsActions.updateRelay(update)))
+ .then( () => dispatch(settingsActions.updateRelay({
+ host: preferredServer,
+ })))
.then( () => backend.connect())
.catch( e => log.error('Failed updating relay constraints', e.message));