diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-05-19 14:30:32 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-05-19 14:30:32 +0200 |
| commit | 8f6bf74b9364ffcb9c95aa21e4acf731d4bfa309 (patch) | |
| tree | ad228533b5a7833344faacf0539b5b0142a2ac01 /gui | |
| parent | 32030011e21286a151a5adff1a14c054efa933cf (diff) | |
| parent | b4d6c0e96616a4619205c40ded737ae7c40157f5 (diff) | |
| download | mullvadvpn-8f6bf74b9364ffcb9c95aa21e4acf731d4bfa309.tar.xz mullvadvpn-8f6bf74b9364ffcb9c95aa21e4acf731d4bfa309.zip | |
Merge branch 'fix-account-expiry-view'
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/src/renderer/components/MainView.tsx | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/gui/src/renderer/components/MainView.tsx b/gui/src/renderer/components/MainView.tsx index ea678aa061..f59097854e 100644 --- a/gui/src/renderer/components/MainView.tsx +++ b/gui/src/renderer/components/MainView.tsx @@ -7,6 +7,8 @@ import { useHistory } from '../lib/history'; import { RoutePath } from '../lib/routes'; import { useSelector } from '../redux/store'; +type ExpiryData = { show: false } | { show: true; expiry: string | undefined }; + export default function MainView() { const history = useHistory(); const accountExpiry = useSelector((state) => state.account.expiry); @@ -15,19 +17,26 @@ export default function MainView() { (state) => state.account.status.type === 'ok' && state.account.status.method === 'new_account', ); - const [showAccountExpired, setShowAccountExpired] = useState<boolean>( - isNewAccount || accountHasExpired, + const [showAccountExpired, setShowAccountExpired] = useState<ExpiryData>(() => + isNewAccount || accountHasExpired ? { show: true, expiry: accountExpiry } : { show: false }, ); useEffect(() => { - if (accountHasExpired) { - setShowAccountExpired(true); - } else if (showAccountExpired && !accountHasExpired) { + if ( + accountHasExpired && + (!showAccountExpired.show || showAccountExpired.expiry !== accountExpiry) + ) { + setShowAccountExpired({ show: true, expiry: accountExpiry }); + } else if ( + showAccountExpired.show && + accountExpiry !== showAccountExpired.expiry && + !accountHasExpired + ) { history.push(RoutePath.timeAdded); } }, [showAccountExpired, accountHasExpired]); - if (showAccountExpired) { + if (showAccountExpired.show) { return <ExpiredAccountErrorViewContainer />; } else { return <ConnectPage />; |
