diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-11-22 10:02:42 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-11-24 16:26:28 +0100 |
| commit | 494d2795d433ae52ed588b6405b87cf0ed7f96e7 (patch) | |
| tree | 5ce67f3c9a053a5760515b82e30c922e8b68d0e8 /gui/src | |
| parent | 7cb83a297635c6f196b17d219e24f364eecd862f (diff) | |
| download | mullvadvpn-494d2795d433ae52ed588b6405b87cf0ed7f96e7.tar.xz mullvadvpn-494d2795d433ae52ed588b6405b87cf0ed7f96e7.zip | |
Switch to exit location tab after selecting entry location
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/components/select-location/select-location-hooks.ts | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gui/src/renderer/components/select-location/select-location-hooks.ts b/gui/src/renderer/components/select-location/select-location-hooks.ts index 2e6b412b8f..a29681ba25 100644 --- a/gui/src/renderer/components/select-location/select-location-hooks.ts +++ b/gui/src/renderer/components/select-location/select-location-hooks.ts @@ -16,17 +16,14 @@ import { } from './select-location-types'; import { useSelectLocationContext } from './SelectLocationContainer'; -// Functions for handling selection of locations export function useOnSelectLocation() { const history = useHistory(); - const { updateRelaySettings } = useAppContext(); - const { locationType } = useSelectLocationContext(); + const { updateRelaySettings, connectTunnel } = useAppContext(); + const { locationType, setLocationType } = useSelectLocationContext(); const baseRelaySettings = useSelector((state) => state.settings.relaySettings); const onSelectLocation = useCallback( async (relayUpdate: RelaySettingsUpdate) => { - // dismiss the view first - history.dismiss(); try { await updateRelaySettings(relayUpdate); } catch (e) { @@ -39,15 +36,18 @@ export function useOnSelectLocation() { const onSelectExitLocation = useCallback( async (relayLocation: LocationSelection<never>) => { + history.dismiss(); const relayUpdate = RelaySettingsBuilder.normal() .location.fromRaw(relayLocation.value) .build(); await onSelectLocation(relayUpdate); + await connectTunnel(); }, - [onSelectLocation], + [onSelectLocation, history], ); const onSelectEntryLocation = useCallback( async (entryLocation: LocationSelection<never>) => { + setLocationType(LocationType.exit); const relayUpdate = createWireguardRelayUpdater(baseRelaySettings) .tunnel.wireguard((wireguard) => wireguard.entryLocation.exact(entryLocation.value)) .build(); @@ -62,12 +62,10 @@ export function useOnSelectLocation() { export function useOnSelectBridgeLocation() { const history = useHistory(); const { updateBridgeSettings } = useAppContext(); + const { setLocationType } = useSelectLocationContext(); return useCallback( async (location: LocationSelection<SpecialBridgeLocationType>) => { - // dismiss the view first - history.dismiss(); - let bridgeUpdate; if (location.type === LocationSelectionType.relay) { bridgeUpdate = new BridgeSettingsBuilder().location.fromRaw(location.value).build(); @@ -79,6 +77,7 @@ export function useOnSelectBridgeLocation() { } if (bridgeUpdate) { + setLocationType(LocationType.exit); try { await updateBridgeSettings(bridgeUpdate); } catch (e) { |
