summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-12-08 15:46:21 +0100
committerOskar Nyberg <oskar@mullvad.net>2022-03-14 13:58:44 +0100
commit8fc9e85b9d533cd0afe94e4b027589894c6344d9 (patch)
treecff7b52d56dc1244a95d827b3d85ea27c9e92ac0 /gui/src
parenta22ec1ee2833364839fae53cbbb4dc16030ed8ce (diff)
downloadmullvadvpn-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.tsx52
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);
+ }
}
}