diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-11-12 15:26:28 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-03-14 13:58:44 +0100 |
| commit | 940e39e38b942c04484acc2906f5a3bf77fe4897 (patch) | |
| tree | a2a8fea639781c2716ed76e27be953cb6a1ec929 /gui/src | |
| parent | 8d03e12c3021d3c08bc3335f2e39f229d4b337fc (diff) | |
| download | mullvadvpn-940e39e38b942c04484acc2906f5a3bf77fe4897.tar.xz mullvadvpn-940e39e38b942c04484acc2906f5a3bf77fe4897.zip | |
Add correct transitions for too many devices view
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/app.tsx | 33 | ||||
| -rw-r--r-- | gui/src/renderer/components/TooManyDevices.tsx | 7 |
2 files changed, 21 insertions, 19 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 33fd540a20..eb6ccb1a11 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -279,7 +279,7 @@ export default class AppRenderer { if (error.message === 'Too many devices') { actions.account.loginTooManyDevices(error); this.loginState = 'too many devices'; - this.history.push(RoutePath.tooManyDevices); + this.history.reset(RoutePath.tooManyDevices, transitions.push); } else { actions.account.loginFailed(error); } @@ -638,36 +638,37 @@ export default class AppRenderer { private resetNavigation() { if (this.history) { - const pathname = this.history.location.pathname; + const pathname = this.history.location.pathname as RoutePath; const nextPath = this.getNavigationBase( this.connectedToDaemon, this.deviceConfig?.accountToken, - ); + ) as RoutePath; // First level contains the possible next locations and the second level contains the possible // current locations. - const navigationTransitions: { - [from: string]: { [to: string]: ITransitionSpecification }; - } = { - '/': { - '/login': transitions.pop, - '/main': transitions.pop, + const navigationTransitions: Partial< + Record<RoutePath, Partial<Record<RoutePath | '*', ITransitionSpecification>>> + > = { + [RoutePath.launch]: { + [RoutePath.login]: transitions.pop, + [RoutePath.main]: transitions.pop, '*': transitions.dismiss, }, - '/login': { - '/': transitions.push, - '/main': transitions.pop, + [RoutePath.login]: { + [RoutePath.launch]: transitions.push, + [RoutePath.main]: transitions.pop, '*': transitions.none, }, - '/main': { - '/': transitions.push, - '/login': transitions.push, + [RoutePath.main]: { + [RoutePath.launch]: transitions.push, + [RoutePath.login]: transitions.push, + [RoutePath.tooManyDevices]: transitions.push, '*': transitions.dismiss, }, }; const transition = - navigationTransitions[nextPath][pathname] ?? navigationTransitions[nextPath]['*']; + navigationTransitions[nextPath]?.[pathname] ?? navigationTransitions[nextPath]?.['*']; this.history.reset(nextPath, transition); } } diff --git a/gui/src/renderer/components/TooManyDevices.tsx b/gui/src/renderer/components/TooManyDevices.tsx index 1075071cdd..7b434468c7 100644 --- a/gui/src/renderer/components/TooManyDevices.tsx +++ b/gui/src/renderer/components/TooManyDevices.tsx @@ -5,7 +5,8 @@ import { colors } from '../../config.json'; import { IDevice } from '../../shared/daemon-rpc-types'; import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; -import { useHistory } from '../lib/history'; +import { transitions, useHistory } from '../lib/history'; +import { RoutePath } from '../lib/routes'; import { useBoolean } from '../lib/utilityHooks'; import { useSelector } from '../redux/store'; import * as AppButton from './AppButton'; @@ -109,8 +110,8 @@ export default function TooManyDevices() { const continueLogin = useCallback(() => login(accountToken), [login, accountToken]); const cancel = useCallback(() => { cancelLogin(); - history.pop(); - }, [history.pop, cancelLogin]); + history.reset(RoutePath.login, transitions.pop); + }, [history.reset, cancelLogin]); useEffect(() => void fetchDevices(), []); |
