diff options
| author | Oskar <oskar@mullvad.net> | 2024-10-11 17:11:54 +0200 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2024-10-22 15:18:10 +0200 |
| commit | 2deedc796ab42b8b20fa9db0e2d048ba11c2e21f (patch) | |
| tree | cf84c77cfd9d1a6f224c48ba53e10c082af9e1e4 /gui/src | |
| parent | 1666ff934d648dc88f213a90dde96b1b0eca7692 (diff) | |
| download | mullvadvpn-2deedc796ab42b8b20fa9db0e2d048ba11c2e21f.tar.xz mullvadvpn-2deedc796ab42b8b20fa9db0e2d048ba11c2e21f.zip | |
Split utility-hooks into two files
Diffstat (limited to 'gui/src')
52 files changed, 80 insertions, 77 deletions
diff --git a/gui/src/renderer/components/Account.tsx b/gui/src/renderer/components/Account.tsx index 8459bae6ba..1cc666910e 100644 --- a/gui/src/renderer/components/Account.tsx +++ b/gui/src/renderer/components/Account.tsx @@ -5,7 +5,7 @@ import { formatDate, hasExpired } from '../../shared/account-expiry'; import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; import { useHistory } from '../lib/history'; -import { useEffectEvent } from '../lib/utilityHooks'; +import { useEffectEvent } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import AccountNumberLabel from './AccountNumberLabel'; import { diff --git a/gui/src/renderer/components/ApiAccessMethods.tsx b/gui/src/renderer/components/ApiAccessMethods.tsx index b577e736b3..57668df787 100644 --- a/gui/src/renderer/components/ApiAccessMethods.tsx +++ b/gui/src/renderer/components/ApiAccessMethods.tsx @@ -10,7 +10,7 @@ import { useApiAccessMethodTest } from '../lib/api-access-methods'; import { useHistory } from '../lib/history'; import { generateRoutePath } from '../lib/routeHelpers'; import { RoutePath } from '../lib/routes'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import * as Cell from './cell'; import { diff --git a/gui/src/renderer/components/AppButton.tsx b/gui/src/renderer/components/AppButton.tsx index 2271355f5c..f82b997cc4 100644 --- a/gui/src/renderer/components/AppButton.tsx +++ b/gui/src/renderer/components/AppButton.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { colors } from '../../config.json'; import log from '../../shared/logging'; -import { useMounted } from '../lib/utilityHooks'; +import { useMounted } from '../lib/utility-hooks'; import { StyledButtonContent, StyledHiddenSide, diff --git a/gui/src/renderer/components/Changelog.tsx b/gui/src/renderer/components/Changelog.tsx index 2121f0b552..ea1b42f5c2 100644 --- a/gui/src/renderer/components/Changelog.tsx +++ b/gui/src/renderer/components/Changelog.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import * as AppButton from './AppButton'; import { hugeText, smallText } from './common-styles'; diff --git a/gui/src/renderer/components/ClipboardLabel.tsx b/gui/src/renderer/components/ClipboardLabel.tsx index e9f760fd07..7f1970ebfc 100644 --- a/gui/src/renderer/components/ClipboardLabel.tsx +++ b/gui/src/renderer/components/ClipboardLabel.tsx @@ -5,7 +5,7 @@ import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; import log from '../../shared/logging'; import { useScheduler } from '../../shared/scheduler'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import ImageView from './ImageView'; const COPIED_ICON_DURATION = 2000; diff --git a/gui/src/renderer/components/ContextMenu.tsx b/gui/src/renderer/components/ContextMenu.tsx index e72df94f20..fd84a8f0d9 100644 --- a/gui/src/renderer/components/ContextMenu.tsx +++ b/gui/src/renderer/components/ContextMenu.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useContext, useEffect, useMemo } from 'react'; import styled from 'styled-components'; import { colors } from '../../config.json'; -import { useBoolean, useStyledRef } from '../lib/utilityHooks'; +import { useBoolean, useStyledRef } from '../lib/utility-hooks'; import { smallText } from './common-styles'; import { BackAction } from './KeyboardNavigation'; diff --git a/gui/src/renderer/components/CustomDnsSettings.tsx b/gui/src/renderer/components/CustomDnsSettings.tsx index 1d3eb0a660..914f7b8406 100644 --- a/gui/src/renderer/components/CustomDnsSettings.tsx +++ b/gui/src/renderer/components/CustomDnsSettings.tsx @@ -6,7 +6,7 @@ import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; import { formatHtml } from '../lib/html-formatter'; import { IpAddress } from '../lib/ip'; -import { useBoolean, useMounted, useStyledRef } from '../lib/utilityHooks'; +import { useBoolean, useMounted, useStyledRef } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import Accordion from './Accordion'; import * as AppButton from './AppButton'; diff --git a/gui/src/renderer/components/DaitaSettings.tsx b/gui/src/renderer/components/DaitaSettings.tsx index c5f07ad0c8..bcfca03316 100644 --- a/gui/src/renderer/components/DaitaSettings.tsx +++ b/gui/src/renderer/components/DaitaSettings.tsx @@ -6,7 +6,7 @@ import { strings } from '../../config.json'; import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; import { useHistory } from '../lib/history'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import { AriaDescription, AriaInput, AriaInputGroup, AriaLabel } from './AriaGroup'; import * as Cell from './cell'; diff --git a/gui/src/renderer/components/Debug.tsx b/gui/src/renderer/components/Debug.tsx index f81fb85402..58e446be47 100644 --- a/gui/src/renderer/components/Debug.tsx +++ b/gui/src/renderer/components/Debug.tsx @@ -2,7 +2,7 @@ import { useCallback } from 'react'; import styled from 'styled-components'; import { useHistory } from '../lib/history'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import * as AppButton from './AppButton'; import { measurements } from './common-styles'; import { BackAction } from './KeyboardNavigation'; diff --git a/gui/src/renderer/components/DeviceInfoButton.tsx b/gui/src/renderer/components/DeviceInfoButton.tsx index 4839866972..090bb9c8df 100644 --- a/gui/src/renderer/components/DeviceInfoButton.tsx +++ b/gui/src/renderer/components/DeviceInfoButton.tsx @@ -1,7 +1,7 @@ import styled from 'styled-components'; import { messages } from '../../shared/gettext'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import * as AppButton from './AppButton'; import { InfoIcon } from './InfoButton'; import { ModalAlert, ModalAlertType, ModalMessage } from './Modal'; diff --git a/gui/src/renderer/components/EditApiAccessMethod.tsx b/gui/src/renderer/components/EditApiAccessMethod.tsx index 470f34a064..8a11404b1c 100644 --- a/gui/src/renderer/components/EditApiAccessMethod.tsx +++ b/gui/src/renderer/components/EditApiAccessMethod.tsx @@ -12,7 +12,7 @@ import { useScheduler } from '../../shared/scheduler'; import { useAppContext } from '../context'; import { useApiAccessMethodTest } from '../lib/api-access-methods'; import { useHistory } from '../lib/history'; -import { useLastDefinedValue } from '../lib/utilityHooks'; +import { useLastDefinedValue } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import { SettingsForm } from './cell/SettingsForm'; import { BackAction } from './KeyboardNavigation'; diff --git a/gui/src/renderer/components/EditCustomBridge.tsx b/gui/src/renderer/components/EditCustomBridge.tsx index ec33ed2a24..7a0ad6f8d8 100644 --- a/gui/src/renderer/components/EditCustomBridge.tsx +++ b/gui/src/renderer/components/EditCustomBridge.tsx @@ -4,7 +4,7 @@ import { CustomProxy } from '../../shared/daemon-rpc-types'; import { messages } from '../../shared/gettext'; import { useBridgeSettingsUpdater } from '../lib/constraint-updater'; import { useHistory } from '../lib/history'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import { SettingsForm } from './cell/SettingsForm'; import { BackAction } from './KeyboardNavigation'; diff --git a/gui/src/renderer/components/Filter.tsx b/gui/src/renderer/components/Filter.tsx index 9040afcfca..a0ed1725b1 100644 --- a/gui/src/renderer/components/Filter.tsx +++ b/gui/src/renderer/components/Filter.tsx @@ -11,7 +11,8 @@ import { filterLocationsByEndPointType, } from '../lib/filter-locations'; import { useHistory } from '../lib/history'; -import { useBoolean, useNormalRelaySettings, useTunnelProtocol } from '../lib/utilityHooks'; +import { useNormalRelaySettings, useTunnelProtocol } from '../lib/relay-settings-hooks'; +import { useBoolean } from '../lib/utility-hooks'; import { IRelayLocationCountryRedux } from '../redux/settings/reducers'; import { useSelector } from '../redux/store'; import Accordion from './Accordion'; diff --git a/gui/src/renderer/components/FormattableTextInput.tsx b/gui/src/renderer/components/FormattableTextInput.tsx index dd78545966..aae614ddd7 100644 --- a/gui/src/renderer/components/FormattableTextInput.tsx +++ b/gui/src/renderer/components/FormattableTextInput.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect } from 'react'; -import { useCombinedRefs, useStyledRef } from '../lib/utilityHooks'; +import { useCombinedRefs, useStyledRef } from '../lib/utility-hooks'; interface IFormattableTextInputProps extends React.InputHTMLAttributes<HTMLInputElement> { allowedCharacters: string; diff --git a/gui/src/renderer/components/InfoButton.tsx b/gui/src/renderer/components/InfoButton.tsx index e17e7b87b8..4ef2aa3c6e 100644 --- a/gui/src/renderer/components/InfoButton.tsx +++ b/gui/src/renderer/components/InfoButton.tsx @@ -2,7 +2,7 @@ import styled from 'styled-components'; import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import * as AppButton from './AppButton'; import ImageView from './ImageView'; import { ModalAlert, ModalAlertType } from './Modal'; diff --git a/gui/src/renderer/components/KeyboardNavigation.tsx b/gui/src/renderer/components/KeyboardNavigation.tsx index 28a8be17f3..cbde4297bd 100644 --- a/gui/src/renderer/components/KeyboardNavigation.tsx +++ b/gui/src/renderer/components/KeyboardNavigation.tsx @@ -4,7 +4,7 @@ import { useLocation } from 'react-router'; import { useHistory } from '../lib/history'; import { disableDismissForRoutes } from '../lib/routeHelpers'; import { RoutePath } from '../lib/routes'; -import { useEffectEvent } from '../lib/utilityHooks'; +import { useEffectEvent } from '../lib/utility-hooks'; interface IKeyboardNavigationProps { children: React.ReactElement | Array<React.ReactElement>; diff --git a/gui/src/renderer/components/Launch.tsx b/gui/src/renderer/components/Launch.tsx index 311979709e..7a8f75bc9c 100644 --- a/gui/src/renderer/components/Launch.tsx +++ b/gui/src/renderer/components/Launch.tsx @@ -6,7 +6,7 @@ import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; import { transitions, useHistory } from '../lib/history'; import { RoutePath } from '../lib/routes'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import * as AppButton from './AppButton'; import { measurements, tinyText } from './common-styles'; diff --git a/gui/src/renderer/components/List.tsx b/gui/src/renderer/components/List.tsx index ce38ed293b..4961855fba 100644 --- a/gui/src/renderer/components/List.tsx +++ b/gui/src/renderer/components/List.tsx @@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import styled from 'styled-components'; import { Scheduler } from '../../shared/scheduler'; -import { useEffectEvent } from '../lib/utilityHooks'; +import { useEffectEvent } from '../lib/utility-hooks'; import Accordion from './Accordion'; export const stringValueAsKey = (value: string): string => value; diff --git a/gui/src/renderer/components/MacOsScrollbarDetection.tsx b/gui/src/renderer/components/MacOsScrollbarDetection.tsx index d13ea4e068..520b6f3f3b 100644 --- a/gui/src/renderer/components/MacOsScrollbarDetection.tsx +++ b/gui/src/renderer/components/MacOsScrollbarDetection.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { MacOsScrollbarVisibility } from '../../shared/ipc-schema'; import useActions from '../lib/actionsHook'; -import { useEffectEvent, useStyledRef } from '../lib/utilityHooks'; +import { useEffectEvent, useStyledRef } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import userInterface from '../redux/userinterface/actions'; diff --git a/gui/src/renderer/components/Map.tsx b/gui/src/renderer/components/Map.tsx index 8b3f66b50e..9ea69251d9 100644 --- a/gui/src/renderer/components/Map.tsx +++ b/gui/src/renderer/components/Map.tsx @@ -10,7 +10,7 @@ import { useEffectEvent, useRefCallback, useRerenderer, -} from '../lib/utilityHooks'; +} from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; // Default to Gothenburg when we don't know the actual location. @@ -90,6 +90,7 @@ function MapInner(props: MapInnerProps) { const mapRef = useRef<GlMap>(); const canvasRef = useRef<HTMLCanvasElement>(); + // eslint-disable-next-line react-compiler/react-compiler const width = applyPixelRatio(canvasRef.current?.clientWidth ?? window.innerWidth); diff --git a/gui/src/renderer/components/Modal.tsx b/gui/src/renderer/components/Modal.tsx index cbce07b4d8..e339566c24 100644 --- a/gui/src/renderer/components/Modal.tsx +++ b/gui/src/renderer/components/Modal.tsx @@ -4,7 +4,7 @@ import styled from 'styled-components'; import { colors } from '../../config.json'; import log from '../../shared/logging'; -import { useEffectEvent } from '../lib/utilityHooks'; +import { useEffectEvent } from '../lib/utility-hooks'; import { useWillExit } from '../lib/will-exit'; import * as AppButton from './AppButton'; import { measurements, normalText, tinyText } from './common-styles'; diff --git a/gui/src/renderer/components/NavigationBar.tsx b/gui/src/renderer/components/NavigationBar.tsx index 48a8a3d08d..680393a6c7 100644 --- a/gui/src/renderer/components/NavigationBar.tsx +++ b/gui/src/renderer/components/NavigationBar.tsx @@ -5,7 +5,7 @@ import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; import { transitions, useHistory } from '../lib/history'; -import { useCombinedRefs, useEffectEvent } from '../lib/utilityHooks'; +import { useCombinedRefs, useEffectEvent } from '../lib/utility-hooks'; import CustomScrollbars, { CustomScrollbarsRef, IScrollEvent } from './CustomScrollbars'; import InfoButton from './InfoButton'; import { BackActionContext } from './KeyboardNavigation'; diff --git a/gui/src/renderer/components/NotificationBanner.tsx b/gui/src/renderer/components/NotificationBanner.tsx index d5cedbb270..924f65ff99 100644 --- a/gui/src/renderer/components/NotificationBanner.tsx +++ b/gui/src/renderer/components/NotificationBanner.tsx @@ -4,7 +4,7 @@ import styled from 'styled-components'; import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; import { InAppNotificationIndicatorType } from '../../shared/notifications/notification'; -import { useEffectEvent, useLastDefinedValue, useStyledRef } from '../lib/utilityHooks'; +import { useEffectEvent, useLastDefinedValue, useStyledRef } from '../lib/utility-hooks'; import * as AppButton from './AppButton'; import { tinyText } from './common-styles'; import ImageView from './ImageView'; diff --git a/gui/src/renderer/components/OpenVpnSettings.tsx b/gui/src/renderer/components/OpenVpnSettings.tsx index 5013b158f8..571e8e3571 100644 --- a/gui/src/renderer/components/OpenVpnSettings.tsx +++ b/gui/src/renderer/components/OpenVpnSettings.tsx @@ -16,7 +16,7 @@ import { useAppContext } from '../context'; import { useRelaySettingsUpdater } from '../lib/constraint-updater'; import { useHistory } from '../lib/history'; import { formatHtml } from '../lib/html-formatter'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import { AriaDescription, AriaInput, AriaInputGroup, AriaLabel } from './AriaGroup'; import * as Cell from './cell'; diff --git a/gui/src/renderer/components/PageSlider.tsx b/gui/src/renderer/components/PageSlider.tsx index 54129b9357..d03c90a0e2 100644 --- a/gui/src/renderer/components/PageSlider.tsx +++ b/gui/src/renderer/components/PageSlider.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { colors } from '../../config.json'; import { NonEmptyArray } from '../../shared/utils'; -import { useStyledRef } from '../lib/utilityHooks'; +import { useStyledRef } from '../lib/utility-hooks'; import { Icon } from './cell'; const PAGE_GAP = 16; diff --git a/gui/src/renderer/components/ProblemReport.tsx b/gui/src/renderer/components/ProblemReport.tsx index fcf53e4a38..36ddc09c45 100644 --- a/gui/src/renderer/components/ProblemReport.tsx +++ b/gui/src/renderer/components/ProblemReport.tsx @@ -17,7 +17,7 @@ import { getDownloadUrl } from '../../shared/version'; import { useAppContext } from '../context'; import useActions from '../lib/actionsHook'; import { useHistory } from '../lib/history'; -import { useEffectEvent } from '../lib/utilityHooks'; +import { useEffectEvent } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import support from '../redux/support/actions'; import * as AppButton from './AppButton'; diff --git a/gui/src/renderer/components/ProxyForm.tsx b/gui/src/renderer/components/ProxyForm.tsx index 273669f85e..9a163ceebf 100644 --- a/gui/src/renderer/components/ProxyForm.tsx +++ b/gui/src/renderer/components/ProxyForm.tsx @@ -11,7 +11,7 @@ import { } from '../../shared/daemon-rpc-types'; import { messages } from '../../shared/gettext'; import { IpAddress } from '../lib/ip'; -import { useEffectEvent } from '../lib/utilityHooks'; +import { useEffectEvent } from '../lib/utility-hooks'; import * as Cell from './cell'; import { SettingsForm, useSettingsFormSubmittable } from './cell/SettingsForm'; import { SettingsGroup } from './cell/SettingsGroup'; diff --git a/gui/src/renderer/components/SearchBar.tsx b/gui/src/renderer/components/SearchBar.tsx index b84389c75f..fe1d1936aa 100644 --- a/gui/src/renderer/components/SearchBar.tsx +++ b/gui/src/renderer/components/SearchBar.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; -import { useEffectEvent, useStyledRef } from '../lib/utilityHooks'; +import { useEffectEvent, useStyledRef } from '../lib/utility-hooks'; import { normalText } from './common-styles'; import ImageView from './ImageView'; diff --git a/gui/src/renderer/components/SettingsImport.tsx b/gui/src/renderer/components/SettingsImport.tsx index 6a596d8c04..8fefbedf20 100644 --- a/gui/src/renderer/components/SettingsImport.tsx +++ b/gui/src/renderer/components/SettingsImport.tsx @@ -9,7 +9,7 @@ import { useAppContext } from '../context'; import useActions from '../lib/actionsHook'; import { transitions, useHistory } from '../lib/history'; import { RoutePath } from '../lib/routes'; -import { useBoolean, useEffectEvent } from '../lib/utilityHooks'; +import { useBoolean, useEffectEvent } from '../lib/utility-hooks'; import settingsImportActions from '../redux/settings-import/actions'; import { useSelector } from '../redux/store'; import { measurements, normalText } from './common-styles'; diff --git a/gui/src/renderer/components/SettingsTextImport.tsx b/gui/src/renderer/components/SettingsTextImport.tsx index 1c6c223972..c6cb325b0c 100644 --- a/gui/src/renderer/components/SettingsTextImport.tsx +++ b/gui/src/renderer/components/SettingsTextImport.tsx @@ -5,7 +5,7 @@ import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; import useActions from '../lib/actionsHook'; import { useHistory } from '../lib/history'; -import { useCombinedRefs, useRefCallback, useStyledRef } from '../lib/utilityHooks'; +import { useCombinedRefs, useRefCallback, useStyledRef } from '../lib/utility-hooks'; import settingsImportActions from '../redux/settings-import/actions'; import { useSelector } from '../redux/store'; import ImageView from './ImageView'; diff --git a/gui/src/renderer/components/SimpleInput.tsx b/gui/src/renderer/components/SimpleInput.tsx index 82a561bb7d..8d4a51d8e9 100644 --- a/gui/src/renderer/components/SimpleInput.tsx +++ b/gui/src/renderer/components/SimpleInput.tsx @@ -2,7 +2,7 @@ import { useCallback, useState } from 'react'; import React from 'react'; import styled from 'styled-components'; -import { useCombinedRefs } from '../lib/utilityHooks'; +import { useCombinedRefs } from '../lib/utility-hooks'; import { normalText } from './common-styles'; const StyledInput = styled.input.attrs({ type: 'text' })(normalText, { diff --git a/gui/src/renderer/components/SplitTunnelingSettings.tsx b/gui/src/renderer/components/SplitTunnelingSettings.tsx index 6451dd0615..ed999ba867 100644 --- a/gui/src/renderer/components/SplitTunnelingSettings.tsx +++ b/gui/src/renderer/components/SplitTunnelingSettings.tsx @@ -12,7 +12,7 @@ import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; import { useHistory } from '../lib/history'; import { formatHtml } from '../lib/html-formatter'; -import { useEffectEvent, useStyledRef } from '../lib/utilityHooks'; +import { useEffectEvent, useStyledRef } from '../lib/utility-hooks'; import { IReduxState } from '../redux/store'; import Accordion from './Accordion'; import * as AppButton from './AppButton'; diff --git a/gui/src/renderer/components/TooManyDevices.tsx b/gui/src/renderer/components/TooManyDevices.tsx index 9ebd2022b4..3e636bcb44 100644 --- a/gui/src/renderer/components/TooManyDevices.tsx +++ b/gui/src/renderer/components/TooManyDevices.tsx @@ -11,7 +11,7 @@ import { useAppContext } from '../context'; import { transitions, useHistory } from '../lib/history'; import { formatHtml } from '../lib/html-formatter'; import { RoutePath } from '../lib/routes'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import * as AppButton from './AppButton'; import * as Cell from './cell'; diff --git a/gui/src/renderer/components/VpnSettings.tsx b/gui/src/renderer/components/VpnSettings.tsx index b1f6d524eb..c23ecdbf47 100644 --- a/gui/src/renderer/components/VpnSettings.tsx +++ b/gui/src/renderer/components/VpnSettings.tsx @@ -10,8 +10,9 @@ import { useAppContext } from '../context'; import { useRelaySettingsUpdater } from '../lib/constraint-updater'; import { useHistory } from '../lib/history'; import { formatHtml } from '../lib/html-formatter'; +import { useTunnelProtocol } from '../lib/relay-settings-hooks'; import { RoutePath } from '../lib/routes'; -import { useBoolean, useTunnelProtocol } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { RelaySettingsRedux } from '../redux/settings/reducers'; import { useSelector } from '../redux/store'; import * as AppButton from './AppButton'; diff --git a/gui/src/renderer/components/cell/Input.tsx b/gui/src/renderer/components/cell/Input.tsx index 9ff4994e42..de2649e3c6 100644 --- a/gui/src/renderer/components/cell/Input.tsx +++ b/gui/src/renderer/components/cell/Input.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useContext, useEffect, useState } from 'react'; import styled from 'styled-components'; import { colors } from '../../../config.json'; -import { useBoolean, useCombinedRefs, useEffectEvent, useStyledRef } from '../../lib/utilityHooks'; +import { useBoolean, useCombinedRefs, useEffectEvent, useStyledRef } from '../../lib/utility-hooks'; import { normalText } from '../common-styles'; import ImageView from '../ImageView'; import { BackAction } from '../KeyboardNavigation'; diff --git a/gui/src/renderer/components/cell/Section.tsx b/gui/src/renderer/components/cell/Section.tsx index 051730e424..b7465ecb93 100644 --- a/gui/src/renderer/components/cell/Section.tsx +++ b/gui/src/renderer/components/cell/Section.tsx @@ -4,7 +4,7 @@ import styled from 'styled-components'; import { colors } from '../../../config.json'; import { useAppContext } from '../../context'; import { useHistory } from '../../lib/history'; -import { useBoolean, useEffectEvent } from '../../lib/utilityHooks'; +import { useBoolean, useEffectEvent } from '../../lib/utility-hooks'; import Accordion from '../Accordion'; import ChevronButton from '../ChevronButton'; import { buttonText, openSans, sourceSansPro } from '../common-styles'; diff --git a/gui/src/renderer/components/cell/Selector.tsx b/gui/src/renderer/components/cell/Selector.tsx index cd689615e2..b1e20a0c41 100644 --- a/gui/src/renderer/components/cell/Selector.tsx +++ b/gui/src/renderer/components/cell/Selector.tsx @@ -5,7 +5,7 @@ import { colors } from '../../../config.json'; import { messages } from '../../../shared/gettext'; import { useHistory } from '../../lib/history'; import { RoutePath } from '../../lib/routes'; -import { useStyledRef } from '../../lib/utilityHooks'; +import { useStyledRef } from '../../lib/utility-hooks'; import { AriaDetails, AriaInput, AriaLabel } from '../AriaGroup'; import ImageView from '../ImageView'; import InfoButton from '../InfoButton'; diff --git a/gui/src/renderer/components/cell/SettingsForm.tsx b/gui/src/renderer/components/cell/SettingsForm.tsx index f58c750bab..9a901d88d8 100644 --- a/gui/src/renderer/components/cell/SettingsForm.tsx +++ b/gui/src/renderer/components/cell/SettingsForm.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useContext, useEffect, useId, useMemo, useState } from 'react'; -import { useEffectEvent } from '../../lib/utilityHooks'; +import { useEffectEvent } from '../../lib/utility-hooks'; interface SettingsFormContext { formSubmittable: boolean; diff --git a/gui/src/renderer/components/cell/SettingsSelect.tsx b/gui/src/renderer/components/cell/SettingsSelect.tsx index d152b02c0c..7b5e1d7ab4 100644 --- a/gui/src/renderer/components/cell/SettingsSelect.tsx +++ b/gui/src/renderer/components/cell/SettingsSelect.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { colors } from '../../../config.json'; import { useScheduler } from '../../../shared/scheduler'; -import { useBoolean, useEffectEvent } from '../../lib/utilityHooks'; +import { useBoolean, useEffectEvent } from '../../lib/utility-hooks'; import { AriaInput } from '../AriaGroup'; import { smallNormalText } from '../common-styles'; import CustomScrollbars from '../CustomScrollbars'; diff --git a/gui/src/renderer/components/cell/SettingsTextInput.tsx b/gui/src/renderer/components/cell/SettingsTextInput.tsx index 1b45b49dbc..44381bc681 100644 --- a/gui/src/renderer/components/cell/SettingsTextInput.tsx +++ b/gui/src/renderer/components/cell/SettingsTextInput.tsx @@ -2,7 +2,7 @@ import { useCallback, useEffect } from 'react'; import styled from 'styled-components'; import { colors } from '../../../config.json'; -import { useEffectEvent } from '../../lib/utilityHooks'; +import { useEffectEvent } from '../../lib/utility-hooks'; import { AriaInput } from '../AriaGroup'; import { smallNormalText } from '../common-styles'; import { useSettingsFormSubmittableReporter } from './SettingsForm'; diff --git a/gui/src/renderer/components/main-view/ConnectionPanel.tsx b/gui/src/renderer/components/main-view/ConnectionPanel.tsx index 5b4e576f76..34e98abeea 100644 --- a/gui/src/renderer/components/main-view/ConnectionPanel.tsx +++ b/gui/src/renderer/components/main-view/ConnectionPanel.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect } from 'react'; import styled from 'styled-components'; -import { useBoolean } from '../../lib/utilityHooks'; +import { useBoolean } from '../../lib/utility-hooks'; import { useSelector } from '../../redux/store'; import CustomScrollbars from '../CustomScrollbars'; import { BackAction } from '../KeyboardNavigation'; diff --git a/gui/src/renderer/components/main-view/FeatureIndicators.tsx b/gui/src/renderer/components/main-view/FeatureIndicators.tsx index 695129e2ac..5b7e60ade0 100644 --- a/gui/src/renderer/components/main-view/FeatureIndicators.tsx +++ b/gui/src/renderer/components/main-view/FeatureIndicators.tsx @@ -5,7 +5,7 @@ import styled from 'styled-components'; import { colors, strings } from '../../../config.json'; import { FeatureIndicator } from '../../../shared/daemon-rpc-types'; import { messages } from '../../../shared/gettext'; -import { useStyledRef } from '../../lib/utilityHooks'; +import { useStyledRef } from '../../lib/utility-hooks'; import { useSelector } from '../../redux/store'; import { tinyText } from '../common-styles'; import { InfoIcon } from '../InfoButton'; diff --git a/gui/src/renderer/components/select-location/CustomListDialogs.tsx b/gui/src/renderer/components/select-location/CustomListDialogs.tsx index 8bd9af9b02..4cc42c0623 100644 --- a/gui/src/renderer/components/select-location/CustomListDialogs.tsx +++ b/gui/src/renderer/components/select-location/CustomListDialogs.tsx @@ -13,7 +13,7 @@ import { messages } from '../../../shared/gettext'; import log from '../../../shared/logging'; import { useAppContext } from '../../context'; import { formatHtml } from '../../lib/html-formatter'; -import { useBoolean } from '../../lib/utilityHooks'; +import { useBoolean } from '../../lib/utility-hooks'; import { useSelector } from '../../redux/store'; import * as AppButton from '../AppButton'; import * as Cell from '../cell'; diff --git a/gui/src/renderer/components/select-location/CustomLists.tsx b/gui/src/renderer/components/select-location/CustomLists.tsx index 348baddd23..1f4c77ed6b 100644 --- a/gui/src/renderer/components/select-location/CustomLists.tsx +++ b/gui/src/renderer/components/select-location/CustomLists.tsx @@ -6,7 +6,7 @@ import { CustomListError, CustomLists, RelayLocation } from '../../../shared/dae import { messages } from '../../../shared/gettext'; import log from '../../../shared/logging'; import { useAppContext } from '../../context'; -import { useBoolean, useStyledRef } from '../../lib/utilityHooks'; +import { useBoolean, useStyledRef } from '../../lib/utility-hooks'; import Accordion from '../Accordion'; import * as Cell from '../cell'; import { measurements } from '../common-styles'; diff --git a/gui/src/renderer/components/select-location/LocationRow.tsx b/gui/src/renderer/components/select-location/LocationRow.tsx index 70f0a2765b..a47c1dd646 100644 --- a/gui/src/renderer/components/select-location/LocationRow.tsx +++ b/gui/src/renderer/components/select-location/LocationRow.tsx @@ -9,7 +9,7 @@ import { import { messages } from '../../../shared/gettext'; import log from '../../../shared/logging'; import { useAppContext } from '../../context'; -import { useBoolean, useStyledRef } from '../../lib/utilityHooks'; +import { useBoolean, useStyledRef } from '../../lib/utility-hooks'; import { useSelector } from '../../redux/store'; import Accordion from '../Accordion'; import * as Cell from '../cell'; diff --git a/gui/src/renderer/components/select-location/RelayListContext.tsx b/gui/src/renderer/components/select-location/RelayListContext.tsx index ce9ef9be65..3165a95824 100644 --- a/gui/src/renderer/components/select-location/RelayListContext.tsx +++ b/gui/src/renderer/components/select-location/RelayListContext.tsx @@ -10,11 +10,11 @@ import { searchForLocations, } from '../../lib/filter-locations'; import { - useEffectEvent, useNormalBridgeSettings, useNormalRelaySettings, useTunnelProtocol, -} from '../../lib/utilityHooks'; +} from '../../lib/relay-settings-hooks'; +import { useEffectEvent } from '../../lib/utility-hooks'; import { IRelayLocationCountryRedux } from '../../redux/settings/reducers'; import { useSelector } from '../../redux/store'; import { useCustomListsRelayList } from './custom-list-helpers'; diff --git a/gui/src/renderer/components/select-location/ScrollPositionContext.tsx b/gui/src/renderer/components/select-location/ScrollPositionContext.tsx index 1d72f6abe8..55ee8dae97 100644 --- a/gui/src/renderer/components/select-location/ScrollPositionContext.tsx +++ b/gui/src/renderer/components/select-location/ScrollPositionContext.tsx @@ -2,7 +2,8 @@ import { Action } from 'history'; import React, { useCallback, useContext, useEffect, useMemo, useRef } from 'react'; import { useHistory } from '../../lib/history'; -import { useNormalRelaySettings, useStyledRef } from '../../lib/utilityHooks'; +import { useNormalRelaySettings } from '../../lib/relay-settings-hooks'; +import { useStyledRef } from '../../lib/utility-hooks'; import { CustomScrollbarsRef } from '../CustomScrollbars'; import { LocationType } from './select-location-types'; import { useSelectLocationContext } from './SelectLocationContainer'; diff --git a/gui/src/renderer/components/select-location/SelectLocation.tsx b/gui/src/renderer/components/select-location/SelectLocation.tsx index b48f24844b..506c836548 100644 --- a/gui/src/renderer/components/select-location/SelectLocation.tsx +++ b/gui/src/renderer/components/select-location/SelectLocation.tsx @@ -8,8 +8,8 @@ import { useRelaySettingsUpdater } from '../../lib/constraint-updater'; import { daitaFilterActive, filterSpecialLocations } from '../../lib/filter-locations'; import { useHistory } from '../../lib/history'; import { formatHtml } from '../../lib/html-formatter'; +import { useNormalRelaySettings } from '../../lib/relay-settings-hooks'; import { RoutePath } from '../../lib/routes'; -import { useNormalRelaySettings } from '../../lib/utilityHooks'; import { useSelector } from '../../redux/store'; import * as Cell from '../cell'; import { useFilteredProviders } from '../Filter'; diff --git a/gui/src/renderer/lib/api-access-methods.ts b/gui/src/renderer/lib/api-access-methods.ts index 270d0fbf62..90d406cc3d 100644 --- a/gui/src/renderer/lib/api-access-methods.ts +++ b/gui/src/renderer/lib/api-access-methods.ts @@ -3,7 +3,7 @@ import { useCallback, useRef, useState } from 'react'; import { CustomProxy } from '../../shared/daemon-rpc-types'; import { useScheduler } from '../../shared/scheduler'; import { useAppContext } from '../context'; -import { useBoolean } from './utilityHooks'; +import { useBoolean } from './utility-hooks'; export function useApiAccessMethodTest( autoReset = true, diff --git a/gui/src/renderer/lib/constraint-updater.ts b/gui/src/renderer/lib/constraint-updater.ts index 73fbdd1336..6ea021ece9 100644 --- a/gui/src/renderer/lib/constraint-updater.ts +++ b/gui/src/renderer/lib/constraint-updater.ts @@ -16,7 +16,7 @@ import { NormalRelaySettingsRedux, } from '../redux/settings/reducers'; import { useSelector } from '../redux/store'; -import { useNormalRelaySettings } from './utilityHooks'; +import { useNormalRelaySettings } from './relay-settings-hooks'; export function wrapRelaySettingsOrDefault( relaySettings?: NormalRelaySettingsRedux, diff --git a/gui/src/renderer/lib/relay-settings-hooks.ts b/gui/src/renderer/lib/relay-settings-hooks.ts new file mode 100644 index 0000000000..14fe99849d --- /dev/null +++ b/gui/src/renderer/lib/relay-settings-hooks.ts @@ -0,0 +1,25 @@ +import { LiftedConstraint, TunnelProtocol } from '../../shared/daemon-rpc-types'; +import { useSelector } from '../redux/store'; + +export function useNormalRelaySettings() { + const relaySettings = useSelector((state) => state.settings.relaySettings); + return 'normal' in relaySettings ? relaySettings.normal : undefined; +} + +// Some features are considered core privacy features and when enabled prevent OpenVPN from being +// used. This hook returns the tunnelprotocol with the exception that it always returns WireGuard +// when any of those features are enabled. +export function useTunnelProtocol(): LiftedConstraint<TunnelProtocol> { + const relaySettings = useNormalRelaySettings(); + const multihop = relaySettings?.wireguard.useMultihop ?? false; + const daita = useSelector((state) => state.settings.wireguard.daita?.enabled ?? false); + const quantumResistant = useSelector((state) => state.settings.wireguard.quantumResistant); + const openVpnDisabled = daita || multihop || quantumResistant; + + return openVpnDisabled ? 'wireguard' : (relaySettings?.tunnelProtocol ?? 'any'); +} + +export function useNormalBridgeSettings() { + const bridgeSettings = useSelector((state) => state.settings.bridgeSettings); + return bridgeSettings.normal; +} diff --git a/gui/src/renderer/lib/utilityHooks.ts b/gui/src/renderer/lib/utility-hooks.ts index 865e078b9e..1efc49c804 100644 --- a/gui/src/renderer/lib/utilityHooks.ts +++ b/gui/src/renderer/lib/utility-hooks.ts @@ -1,8 +1,5 @@ import React, { useCallback, useEffect, useInsertionEffect, useRef, useState } from 'react'; -import { LiftedConstraint, TunnelProtocol } from '../../shared/daemon-rpc-types'; -import { useSelector } from '../redux/store'; - export function useMounted() { const mountedRef = useRef(false); const isMounted = useCallback(() => mountedRef.current, []); @@ -43,29 +40,6 @@ export function useBoolean(initialValue = false) { return [value, setTrue, setFalse, toggle] as const; } -export function useNormalRelaySettings() { - const relaySettings = useSelector((state) => state.settings.relaySettings); - return 'normal' in relaySettings ? relaySettings.normal : undefined; -} - -// Some features are considered core privacy features and when enabled prevent OpenVPN from being -// used. This hook returns the tunnelprotocol with the exception that it always returns WireGuard -// when any of those features are enabled. -export function useTunnelProtocol(): LiftedConstraint<TunnelProtocol> { - const relaySettings = useNormalRelaySettings(); - const multihop = relaySettings?.wireguard.useMultihop ?? false; - const daita = useSelector((state) => state.settings.wireguard.daita?.enabled ?? false); - const quantumResistant = useSelector((state) => state.settings.wireguard.quantumResistant); - const openVpnDisabled = daita || multihop || quantumResistant; - - return openVpnDisabled ? 'wireguard' : (relaySettings?.tunnelProtocol ?? 'any'); -} - -export function useNormalBridgeSettings() { - const bridgeSettings = useSelector((state) => state.settings.bridgeSettings); - return bridgeSettings.normal; -} - // This hook returns a function that can be used to force a rerender of a component, and // additionally also returns a variable that can be used to trigger effects as a result. This is a // hack and should be avoided unless there are no better ways. |
