summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2017-12-12 12:52:42 +0100
committerAndrej Mihajlov <and@mullvad.net>2017-12-19 10:32:24 +0100
commit07fda0947a80cb122431284d12e24e6f806b8280 (patch)
treee94c7fe6560d0050bcfec6b03017df3f04952603
parent668ddcd44533f2d8e80f373e0bcd2d9d257e6ed3 (diff)
downloadmullvadvpn-07fda0947a80cb122431284d12e24e6f806b8280.tar.xz
mullvadvpn-07fda0947a80cb122431284d12e24e6f806b8280.zip
Update redux store
-rw-r--r--app/redux/settings/actions.js18
-rw-r--r--app/redux/settings/reducers.js23
-rw-r--r--app/redux/store.js5
-rw-r--r--test/components/Connect.spec.js6
-rw-r--r--test/components/SelectLocation.spec.js3
-rw-r--r--test/components/Settings.spec.js3
6 files changed, 46 insertions, 12 deletions
diff --git a/app/redux/settings/actions.js b/app/redux/settings/actions.js
index 74f8f120f7..c4f7b20efe 100644
--- a/app/redux/settings/actions.js
+++ b/app/redux/settings/actions.js
@@ -1,13 +1,18 @@
// @flow
-import type { RelaySettingsRedux } from './reducers';
+import type { RelaySettingsRedux, RelayLocationsRedux } from './reducers';
export type UpdateRelayAction = {
type: 'UPDATE_RELAY',
relay: RelaySettingsRedux,
};
-export type SettingsAction = UpdateRelayAction;
+export type UpdateRelayLocationsAction = {
+ type: 'UPDATE_RELAY_LOCATIONS',
+ relayLocations: RelayLocationsRedux
+}
+
+export type SettingsAction = UpdateRelayAction | UpdateRelayLocationsAction;
function updateRelay(relay: RelaySettingsRedux): UpdateRelayAction {
return {
@@ -16,4 +21,11 @@ function updateRelay(relay: RelaySettingsRedux): UpdateRelayAction {
};
}
-export default { updateRelay };
+function updateRelayLocations(relayLocations: RelayLocationsRedux): UpdateRelayLocationsAction {
+ return {
+ type: 'UPDATE_RELAY_LOCATIONS',
+ relayLocations: relayLocations,
+ };
+}
+
+export default { updateRelay, updateRelayLocations };
diff --git a/app/redux/settings/reducers.js b/app/redux/settings/reducers.js
index 56548a8d12..779a6306ad 100644
--- a/app/redux/settings/reducers.js
+++ b/app/redux/settings/reducers.js
@@ -1,7 +1,7 @@
// @flow
import type { ReduxAction } from '../store';
-import type { RelayProtocol, RelayLocation } from '../../lib/ipc-facade';
+import type { RelayProtocol, RelayLocation, RelayList } from '../../lib/ipc-facade';
export type RelaySettingsRedux = {|
normal: {
@@ -17,8 +17,11 @@ export type RelaySettingsRedux = {|
}
|};
+export type RelayLocationsRedux = RelayList;
+
export type SettingsReduxState = {
- relaySettings: RelaySettingsRedux
+ relaySettings: RelaySettingsRedux,
+ relayLocations: RelayLocationsRedux,
};
const initialState: SettingsReduxState = {
@@ -29,15 +32,25 @@ const initialState: SettingsReduxState = {
protocol: 'any',
}
},
+ relayLocations: {
+ countries: []
+ },
};
export default function(state: SettingsReduxState = initialState, action: ReduxAction): SettingsReduxState {
- if (action.type === 'UPDATE_RELAY') {
+ switch(action.type) {
+ case 'UPDATE_RELAY':
return { ...state,
relaySettings: action.relay,
};
- }
- return state;
+ case 'UPDATE_RELAY_LOCATIONS':
+ return { ...state,
+ relayLocations: action.relayLocations,
+ };
+
+ default:
+ return state;
+ }
}
diff --git a/app/redux/store.js b/app/redux/store.js
index 3f73574103..d03849c0c4 100644
--- a/app/redux/store.js
+++ b/app/redux/store.js
@@ -26,10 +26,7 @@ export type ReduxState = {
settings: SettingsReduxState
};
-export type ReduxAction = AccountAction
- | SettingsAction
- | ConnectionAction;
-
+export type ReduxAction = AccountAction | SettingsAction | ConnectionAction;
export type ReduxStore = Store<ReduxState, ReduxAction, ReduxDispatch>;
export type ReduxGetState = () => ReduxState;
export type ReduxDispatch = (action: ReduxAction | ReduxThunk) => any;
diff --git a/test/components/Connect.spec.js b/test/components/Connect.spec.js
index 748dd25761..17ede98454 100644
--- a/test/components/Connect.spec.js
+++ b/test/components/Connect.spec.js
@@ -122,6 +122,9 @@ describe('components/Connect', () => {
port: 'any',
}
},
+ relayLocations: {
+ countries: [],
+ },
},
getServerInfo: (location) => {
return servers.find((server) => {
@@ -180,6 +183,9 @@ const defaultProps: ConnectProps = {
port: 'any',
}
},
+ relayLocations: {
+ countries: [],
+ },
},
connection: defaultConnection,
};
diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js
index 439edc1865..099594ca66 100644
--- a/test/components/SelectLocation.spec.js
+++ b/test/components/SelectLocation.spec.js
@@ -17,6 +17,9 @@ describe('components/SelectLocation', () => {
port: 'any',
}
},
+ relayLocations: {
+ countries: [],
+ },
};
const makeProps = (state: SettingsReduxState, mergeProps: $Shape<SelectLocationProps>): SelectLocationProps => {
diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js
index 31a5fa09a9..7b4780ece2 100644
--- a/test/components/Settings.spec.js
+++ b/test/components/Settings.spec.js
@@ -42,6 +42,9 @@ describe('components/Settings', () => {
port: 1301,
},
},
+ relayLocations: {
+ countries: [],
+ },
};
const makeProps = (anAccountState: AccountReduxState, aSettingsState: SettingsReduxState, mergeProps: $Shape<SettingsProps> = {}): SettingsProps => {