diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-12-08 15:46:21 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-03-14 13:58:44 +0100 |
| commit | 8fc9e85b9d533cd0afe94e4b027589894c6344d9 (patch) | |
| tree | cff7b52d56dc1244a95d827b3d85ea27c9e92ac0 /gui/src | |
| parent | a22ec1ee2833364839fae53cbbb4dc16030ed8ce (diff) | |
| download | mullvadvpn-8fc9e85b9d533cd0afe94e4b027589894c6344d9.tar.xz mullvadvpn-8fc9e85b9d533cd0afe94e4b027589894c6344d9.zip | |
Prevent transitioning when resetting navigation to same path
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/app.tsx | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 9f3bb70a04..1ad4a620e5 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -656,32 +656,34 @@ export default class AppRenderer { const pathname = this.history.location.pathname as RoutePath; const nextPath = this.getNavigationBase() as RoutePath; - // First level contains the possible next locations and the second level contains the - // possible current locations. - const navigationTransitions: Partial< - Record<RoutePath, Partial<Record<RoutePath | '*', ITransitionSpecification>>> - > = { - [RoutePath.launch]: { - [RoutePath.login]: transitions.pop, - [RoutePath.main]: transitions.pop, - '*': transitions.dismiss, - }, - [RoutePath.login]: { - [RoutePath.launch]: transitions.push, - [RoutePath.main]: transitions.pop, - '*': transitions.none, - }, - [RoutePath.main]: { - [RoutePath.launch]: transitions.push, - [RoutePath.login]: transitions.push, - [RoutePath.tooManyDevices]: transitions.push, - '*': transitions.dismiss, - }, - }; + if (pathname !== nextPath) { + // First level contains the possible next locations and the second level contains the + // possible current locations. + const navigationTransitions: Partial< + Record<RoutePath, Partial<Record<RoutePath | '*', ITransitionSpecification>>> + > = { + [RoutePath.launch]: { + [RoutePath.login]: transitions.pop, + [RoutePath.main]: transitions.pop, + '*': transitions.dismiss, + }, + [RoutePath.login]: { + [RoutePath.launch]: transitions.push, + [RoutePath.main]: transitions.pop, + '*': transitions.none, + }, + [RoutePath.main]: { + [RoutePath.launch]: transitions.push, + [RoutePath.login]: transitions.push, + [RoutePath.tooManyDevices]: transitions.push, + '*': transitions.dismiss, + }, + }; - const transition = - navigationTransitions[nextPath]?.[pathname] ?? navigationTransitions[nextPath]?.['*']; - this.history.reset(nextPath, transition); + const transition = + navigationTransitions[nextPath]?.[pathname] ?? navigationTransitions[nextPath]?.['*']; + this.history.reset(nextPath, transition); + } } } |
