diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-09-26 16:35:17 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-11-30 10:36:19 +0100 |
| commit | 944f8adc3e4c2e8a7501f147890a51a0f57f5067 (patch) | |
| tree | 2fd23f3da44e153cdab4c0e3ebe6b5798f6bd2d0 /gui/src/renderer/components | |
| parent | b2c24898e5e871f78fc1b65a7f19789a9388a2a2 (diff) | |
| download | mullvadvpn-944f8adc3e4c2e8a7501f147890a51a0f57f5067.tar.xz mullvadvpn-944f8adc3e4c2e8a7501f147890a51a0f57f5067.zip | |
Update MainView to respect accountExpired error state
Diffstat (limited to 'gui/src/renderer/components')
| -rw-r--r-- | gui/src/renderer/components/MainView.tsx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gui/src/renderer/components/MainView.tsx b/gui/src/renderer/components/MainView.tsx index cc2419ddfd..983a33d376 100644 --- a/gui/src/renderer/components/MainView.tsx +++ b/gui/src/renderer/components/MainView.tsx @@ -1,6 +1,7 @@ import { useEffect, useState } from 'react'; import { hasExpired } from '../../shared/account-expiry'; +import { AuthFailedError, ErrorStateCause } from '../../shared/daemon-rpc-types'; import Connect from '../components/Connect'; import { useHistory } from '../lib/history'; import { RoutePath } from '../lib/routes'; @@ -16,6 +17,7 @@ export default function MainView() { const isNewAccount = useSelector( (state) => state.account.status.type === 'ok' && state.account.status.method === 'new_account', ); + const tunnelState = useSelector((state) => state.connection.status); const [showAccountExpired, setShowAccountExpired] = useState<ExpiryData>(() => isNewAccount || accountHasExpired ? { show: true, expiry: accountExpiry } : { show: false }, @@ -23,8 +25,11 @@ export default function MainView() { useEffect(() => { if ( - accountHasExpired && - (!showAccountExpired.show || showAccountExpired.expiry !== accountExpiry) + (!showAccountExpired.show || showAccountExpired.expiry !== accountExpiry) && + (accountHasExpired || + (tunnelState.state === 'error' && + tunnelState.details.cause === ErrorStateCause.authFailed && + tunnelState.details.authFailedError === AuthFailedError.expiredAccount)) ) { setShowAccountExpired({ show: true, expiry: accountExpiry }); } else if ( @@ -34,7 +39,7 @@ export default function MainView() { ) { history.push(RoutePath.timeAdded); } - }, [showAccountExpired, accountHasExpired]); + }, [showAccountExpired, accountHasExpired, tunnelState.state]); if (showAccountExpired.show) { return <ExpiredAccountErrorView />; |
