@@ -7,7 +7,7 @@ import { Trans, useTranslation } from 'react-i18next';
77import { BsPin , BsPinFill , BsShieldFillCheck , BsShieldFillExclamation } from 'react-icons/bs' ;
88import * as commands from '../bridge/commands' ;
99import { Exit , getExitCountry } from '../common/api' ;
10- import { AppContext , ConnectionInProgress , ExitsContext } from '../common/appContext' ;
10+ import { AppContext , ConnectionInProgress , ExitsContext , isConnecting } from '../common/appContext' ;
1111import commonClasses from '../common/common.module.css' ;
1212import { fmtErrorI18n } from '../common/danger' ;
1313import { CityNotFoundError , exitLocation , exitsSortComparator , getExitCountryFlag , getRandomExitFromCity } from '../common/exitUtils' ;
@@ -173,15 +173,16 @@ interface LocationCarProps {
173173
174174function LocationCard ( { exit, connected, onSelect, togglePin, pinned } : LocationCarProps ) {
175175 const { t } = useTranslation ( ) ;
176- const { connectionInProgress, osStatus } = useContext ( AppContext ) ;
176+ const { connectionInProgress, osStatus, vpnConnected } = useContext ( AppContext ) ;
177177 const { internetAvailable } = osStatus ;
178+ const isOffline = ! internetAvailable && ! vpnConnected && ! isConnecting ( connectionInProgress ) ;
178179
179180 const onPinClick = ( e : MouseEvent ) => {
180181 e . stopPropagation ( ) ;
181182 togglePin ( exit ) ;
182183 } ;
183184
184- const disableClick = connectionInProgress !== ConnectionInProgress . UNSET || ! internetAvailable ;
185+ const disableClick = connectionInProgress !== ConnectionInProgress . UNSET || isOffline ;
185186 const cardClasses = [ ] ;
186187 if ( connected ) cardClasses . push ( classes . locationCardConnected ) ;
187188 if ( disableClick ) cardClasses . push ( classes . locationCardDisabled ) ;
@@ -260,9 +261,10 @@ function VpnStatusCard() {
260261 const { t } = useTranslation ( ) ;
261262 const { appStatus, vpnConnected, connectionInProgress, vpnDisconnect, vpnConnect, osStatus } = useContext ( AppContext ) ;
262263 const { internetAvailable } = osStatus ;
264+ const isOffline = ! internetAvailable && ! vpnConnected && ! isConnecting ( connectionInProgress ) ;
263265
264266 const getStatusTitle = ( ) => {
265- if ( ! internetAvailable ) return t ( 'Offline' ) ;
267+ if ( isOffline ) return t ( 'Offline' ) ;
266268 if ( connectionInProgress !== ConnectionInProgress . UNSET && connectionInProgress !== ConnectionInProgress . ChangingLocations ) return t ( connectionInProgress ) + '...' ;
267269 const selectedLocation = appStatus . vpnStatus . connected ?. exit . city_name ;
268270 // vpnConnected <-> vpnStatus.connected.exit defined
@@ -271,12 +273,12 @@ function VpnStatusCard() {
271273 } ;
272274
273275 const getStatusSubtitle = ( ) => {
274- if ( ! internetAvailable ) return t ( 'connectToInternet' ) ;
276+ if ( isOffline ) return t ( 'connectToInternet' ) ;
275277 return vpnConnected ? t ( 'trafficProtected' ) : t ( 'trafficVulnerable' ) ;
276278 } ;
277279
278280 const allowCancel = connectionInProgress === ConnectionInProgress . Connecting || connectionInProgress === ConnectionInProgress . Reconnecting ;
279- const btnDisabled = ! allowCancel && ( connectionInProgress === ConnectionInProgress . Disconnecting || connectionInProgress === ConnectionInProgress . ChangingLocations || ( ! vpnConnected && ! internetAvailable ) ) ;
281+ const btnDisabled = ! allowCancel && ( connectionInProgress === ConnectionInProgress . Disconnecting || connectionInProgress === ConnectionInProgress . ChangingLocations || isOffline ) ;
280282 const buttonDisconnectProps = ( ( allowCancel || vpnConnected ) && ! btnDisabled ) ? theme . other . buttonDisconnectProps : { } ;
281283
282284 const getButtonContent = ( ) => {
@@ -288,7 +290,7 @@ function VpnStatusCard() {
288290
289291 const btnTitle = ( ) => {
290292 if ( ! btnDisabled ) return ;
291- if ( ! internetAvailable ) return t ( 'noInternet' ) ;
293+ if ( isOffline ) return t ( 'noInternet' ) ;
292294 return t ( 'busyConnection' ) ;
293295 } ;
294296
@@ -313,7 +315,7 @@ function VpnStatusCard() {
313315 < Divider my = 'md' />
314316 < Stack justify = 'space-between' w = '100%' >
315317 < CurrentSession />
316- < ExitInfoCollapse exitPubKey = { appStatus . vpnStatus . connected . exit_public_key } connectedExit = { appStatus . vpnStatus . connected . exit } />
318+ < ExitInfoCollapse exitPubKey = { appStatus . vpnStatus . connected . exitPublicKey } connectedExit = { appStatus . vpnStatus . connected . exit } />
317319 </ Stack >
318320 </ >
319321 }
0 commit comments