summaryrefslogtreecommitdiffhomepage
path: root/app/containers
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-01-29 14:47:52 +0100
committerAndrej Mihajlov <and@mullvad.net>2018-01-29 15:16:23 +0100
commit2fdadcd80b2425d6e82082e735de903c6a551d2e (patch)
tree98b10ea04a55542baf67c2cf74c60f1a1ab63099 /app/containers
parentb818240e9fead04e8f5981a44a4237a6a5cd0619 (diff)
downloadmullvadvpn-2fdadcd80b2425d6e82082e735de903c6a551d2e.tar.xz
mullvadvpn-2fdadcd80b2425d6e82082e735de903c6a551d2e.zip
Calculate map offset dynamically and refine the Connect.state
Diffstat (limited to 'app/containers')
-rw-r--r--app/containers/ConnectPage.js37
1 files changed, 36 insertions, 1 deletions
diff --git a/app/containers/ConnectPage.js b/app/containers/ConnectPage.js
index d9f3bd81e7..9ce245a927 100644
--- a/app/containers/ConnectPage.js
+++ b/app/containers/ConnectPage.js
@@ -11,11 +11,46 @@ import { openLink } from '../lib/platform';
import type { ReduxState, ReduxDispatch } from '../redux/store';
import type { SharedRouteProps } from '../routes';
+import type { RelaySettingsRedux, RelayLocationRedux } from '../redux/settings/reducers';
+
+function getRelayName(relaySettings: RelaySettingsRedux, relayLocations: Array<RelayLocationRedux>): string {
+ if(relaySettings.normal) {
+ const location = relaySettings.normal.location;
+
+ if(location === 'any') {
+ return 'Automatic';
+ } else if(location.country) {
+ const country = relayLocations.find(({ code }) => code === location.country);
+ if(country) {
+ return country.name;
+ }
+ } else if(location.city) {
+ const [countryCode, cityCode] = location.city;
+ const country = relayLocations.find(({ code }) => code === countryCode);
+ if(country) {
+ const city = country.cities.find(({ code }) => code === cityCode);
+ if(city) {
+ return city.name;
+ }
+ }
+ }
+
+ return 'Unknown';
+ } else if(relaySettings.custom_tunnel_endpoint) {
+ return 'Custom';
+ } else {
+ throw new Error('Unsupported relay settings.');
+ }
+}
+
const mapStateToProps = (state: ReduxState) => {
return {
accountExpiry: state.account.expiry,
+ selectedRelayName: getRelayName(
+ state.settings.relaySettings,
+ state.settings.relayLocations
+ ),
connection: state.connection,
- settings: state.settings,
};
};