diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2024-04-08 08:18:49 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2024-04-11 17:21:23 +0200 |
| commit | abd2912d013df44c6aea983205c4bc173f6f748b (patch) | |
| tree | 4f69d6b6d5be70941f05e3769644862329ab3092 /gui/src/renderer/components | |
| parent | d8ead1aa606fe9fec9cc0875dc86dd2829324971 (diff) | |
| download | mullvadvpn-abd2912d013df44c6aea983205c4bc173f6f748b.tar.xz mullvadvpn-abd2912d013df44c6aea983205c4bc173f6f748b.zip | |
Move location type state to redux
Diffstat (limited to 'gui/src/renderer/components')
| -rw-r--r-- | gui/src/renderer/components/select-location/SelectLocationContainer.tsx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gui/src/renderer/components/select-location/SelectLocationContainer.tsx b/gui/src/renderer/components/select-location/SelectLocationContainer.tsx index 5843d5e6f4..1d0e5251f7 100644 --- a/gui/src/renderer/components/select-location/SelectLocationContainer.tsx +++ b/gui/src/renderer/components/select-location/SelectLocationContainer.tsx @@ -1,5 +1,8 @@ import React, { useContext, useMemo, useState } from 'react'; +import useActions from '../../lib/actionsHook'; +import { useSelector } from '../../redux/store'; +import userInterface from '../../redux/userinterface/actions'; import { RelayListContextProvider } from './RelayListContext'; import { ScrollPositionContextProvider } from './ScrollPositionContext'; import { LocationType } from './select-location-types'; @@ -20,13 +23,14 @@ export function useSelectLocationContext() { } export default function SelectLocationContainer() { - const [locationType, setLocationType] = useState(LocationType.exit); + const locationType = useSelector((state) => state.userInterface.selectLocationView); + const { setSelectLocationView } = useActions(userInterface); const [searchTerm, setSearchTerm] = useState(''); - const value = useMemo(() => ({ locationType, setLocationType, searchTerm, setSearchTerm }), [ - locationType, - searchTerm, - ]); + const value = useMemo( + () => ({ locationType, setLocationType: setSelectLocationView, searchTerm, setSearchTerm }), + [locationType, searchTerm], + ); return ( <selectLocationContext.Provider value={value}> |
