diff options
Diffstat (limited to 'gui/src/renderer/containers')
| -rw-r--r-- | gui/src/renderer/containers/SelectLocationPage.tsx | 59 |
1 files changed, 1 insertions, 58 deletions
diff --git a/gui/src/renderer/containers/SelectLocationPage.tsx b/gui/src/renderer/containers/SelectLocationPage.tsx index 8d928421f4..3ca4ca94ac 100644 --- a/gui/src/renderer/containers/SelectLocationPage.tsx +++ b/gui/src/renderer/containers/SelectLocationPage.tsx @@ -7,9 +7,9 @@ import RelaySettingsBuilder from '../../shared/relay-settings-builder'; import SelectLocation from '../components/SelectLocation'; import withAppContext, { IAppContext } from '../context'; import { createWireguardRelayUpdater } from '../lib/constraint-updater'; +import filterLocations from '../lib/filter-locations'; import { IHistoryProps, withHistory } from '../lib/history'; import { RoutePath } from '../lib/routes'; -import { IRelayLocationRedux } from '../redux/settings/reducers'; import { IReduxState, ReduxDispatch } from '../redux/store'; const mapStateToProps = (state: IReduxState, props: IHistoryProps & IAppContext) => { @@ -126,63 +126,6 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp }; }; -function filterLocations( - locations: IRelayLocationRedux[], - providers: string[], - ownership: Ownership, -): IRelayLocationRedux[] { - const locationsFilteredByOwnership = filterLocationsByOwnership(locations, ownership); - const locationsFilteredByProvider = filterLocationsByProvider( - locationsFilteredByOwnership, - providers, - ); - - return locationsFilteredByProvider; -} - -function filterLocationsByOwnership( - locations: IRelayLocationRedux[], - ownership: Ownership, -): IRelayLocationRedux[] { - if (ownership === Ownership.any) { - return locations; - } - - const expectOwned = ownership === Ownership.mullvadOwned; - return locations - .map((country) => ({ - ...country, - cities: country.cities - .map((city) => ({ - ...city, - relays: city.relays.filter((relay) => relay.owned === expectOwned), - })) - .filter((city) => city.relays.length > 0), - })) - .filter((country) => country.cities.length > 0); -} - -function filterLocationsByProvider( - locations: IRelayLocationRedux[], - providers: string[], -): IRelayLocationRedux[] { - if (providers.length === 0) { - return locations; - } - - return locations - .map((country) => ({ - ...country, - cities: country.cities - .map((city) => ({ - ...city, - relays: city.relays.filter((relay) => providers.includes(relay.provider)), - })) - .filter((city) => city.relays.length > 0), - })) - .filter((country) => country.cities.length > 0); -} - export default withAppContext( withHistory(connect(mapStateToProps, mapDispatchToProps)(SelectLocation)), ); |
