diff options
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/components/select-location/RelayListContext.tsx | 27 | ||||
| -rw-r--r-- | gui/src/renderer/components/select-location/custom-list-helpers.ts | 12 |
2 files changed, 33 insertions, 6 deletions
diff --git a/gui/src/renderer/components/select-location/RelayListContext.tsx b/gui/src/renderer/components/select-location/RelayListContext.tsx index d0ee5d6e85..86dd7e5467 100644 --- a/gui/src/renderer/components/select-location/RelayListContext.tsx +++ b/gui/src/renderer/components/select-location/RelayListContext.tsx @@ -135,6 +135,15 @@ function useRelayList( const selectedLocation = useSelectedLocation(); const disabledLocation = useDisabledLocation(); + const preventDueToCustomBridgeSelected = usePreventDueToCustomBridgeSelected(); + + const isLocationSelected = useCallback( + (location: RelayLocation) => { + return preventDueToCustomBridgeSelected ? false : isSelected(location, selectedLocation); + }, + [preventDueToCustomBridgeSelected, selectedLocation], + ); + return useMemo(() => { return relayList .map((country) => { @@ -149,7 +158,7 @@ function useRelayList( disabled: countryDisabledReason !== undefined, disabledReason: countryDisabledReason, expanded: isExpanded(countryLocation, expandedLocations), - selected: isSelected(countryLocation, selectedLocation), + selected: isLocationSelected(countryLocation), cities: country.cities .map((city) => { const cityLocation: RelayLocation = { country: country.code, city: city.code }; @@ -164,7 +173,7 @@ function useRelayList( disabled: cityDisabledReason !== undefined, disabledReason: cityDisabledReason, expanded: isExpanded(cityLocation, expandedLocations), - selected: isSelected(cityLocation, selectedLocation), + selected: isLocationSelected(cityLocation), relays: city.relays .map((relay) => { const relayLocation: RelayLocation = { @@ -183,7 +192,7 @@ function useRelayList( location: relayLocation, disabled: relayDisabledReason !== undefined, disabledReason: relayDisabledReason, - selected: isSelected(relayLocation, selectedLocation), + selected: isLocationSelected(relayLocation), }; }) .sort((a, b) => a.hostname.localeCompare(b.hostname, locale, { numeric: true })), @@ -193,7 +202,17 @@ function useRelayList( }; }) .sort((a, b) => a.label.localeCompare(b.label, locale)); - }, [locale, expandedLocations, relayList, selectedLocation, disabledLocation]); + }, [locale, expandedLocations, relayList, disabledLocation, isLocationSelected]); +} + +export function usePreventDueToCustomBridgeSelected(): boolean { + const relaySettings = useNormalRelaySettings(); + const { locationType } = useSelectLocationContext(); + const bridgeSettings = useSelector((state) => state.settings.bridgeSettings); + const isBridgeSelection = + relaySettings?.tunnelProtocol === 'openvpn' && locationType === LocationType.entry; + + return isBridgeSelection && bridgeSettings.type === 'custom'; } // Return all RelayLocations that should be expanded diff --git a/gui/src/renderer/components/select-location/custom-list-helpers.ts b/gui/src/renderer/components/select-location/custom-list-helpers.ts index 799deb8ed3..5cb6d695b8 100644 --- a/gui/src/renderer/components/select-location/custom-list-helpers.ts +++ b/gui/src/renderer/components/select-location/custom-list-helpers.ts @@ -4,7 +4,11 @@ import { ICustomList, RelayLocation } from '../../../shared/daemon-rpc-types'; import { hasValue } from '../../../shared/utils'; import { searchMatch } from '../../lib/filter-locations'; import { useSelector } from '../../redux/store'; -import { useDisabledLocation, useSelectedLocation } from './RelayListContext'; +import { + useDisabledLocation, + usePreventDueToCustomBridgeSelected, + useSelectedLocation, +} from './RelayListContext'; import { isCustomListDisabled, isExpanded, isSelected } from './select-location-helpers'; import { CitySpecification, @@ -26,6 +30,8 @@ export function useCustomListsRelayList( const { searchTerm } = useSelectLocationContext(); const customLists = useSelector((state) => state.settings.customLists); + const preventDueToCustomBridgeSelected = usePreventDueToCustomBridgeSelected(); + // Populate all custom lists with the real location trees for the list locations. return useMemo( () => @@ -34,6 +40,7 @@ export function useCustomListsRelayList( list, relayList, searchTerm, + preventDueToCustomBridgeSelected, selectedLocation, disabledLocation, expandedLocations, @@ -48,6 +55,7 @@ function prepareCustomList( list: ICustomList, fullRelayList: GeographicalRelayList, searchTerm: string, + preventDueToCustomBridgeSelected: boolean, selectedLocation?: RelayLocation, disabledLocation?: { location: RelayLocation; reason: DisabledReason }, expandedLocations?: Array<RelayLocation>, @@ -64,7 +72,7 @@ function prepareCustomList( disabled: disabledReason !== undefined, disabledReason, expanded: isExpanded(location, expandedLocations), - selected: isSelected(location, selectedLocation), + selected: preventDueToCustomBridgeSelected ? false : isSelected(location, selectedLocation), visible: searchMatch(searchTerm, list.name), locations, }; |
