diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-11-02 13:06:58 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-11-02 15:35:43 +0100 |
| commit | 5d690ccbb221c30902b89254707e5d0f44816d3d (patch) | |
| tree | 2f0b54a3abf7f0d941e30a2e3d2ab14d564eda1b /gui/src | |
| parent | 1c6985eebb43d71d6bb56aa1b94a3d133b749e20 (diff) | |
| download | mullvadvpn-5d690ccbb221c30902b89254707e5d0f44816d3d.tar.xz mullvadvpn-5d690ccbb221c30902b89254707e5d0f44816d3d.zip | |
Use location changes to determine previous location
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/routes.tsx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gui/src/renderer/routes.tsx b/gui/src/renderer/routes.tsx index e4256af994..96a7ee4b82 100644 --- a/gui/src/renderer/routes.tsx +++ b/gui/src/renderer/routes.tsx @@ -15,6 +15,7 @@ import SelectLocationPage from './containers/SelectLocationPage'; import SettingsPage from './containers/SettingsPage'; import SupportPage from './containers/SupportPage'; import WireguardKeysPage from './containers/WireguardKeysPage'; +import History from './lib/history'; import { getTransitionProps } from './transitions'; interface IAppRoutesState { @@ -38,12 +39,14 @@ class AppRoutes extends React.Component<RouteComponentProps, IAppRoutesState> { public componentDidMount() { // React throttles updates, so it's impossible to capture the intermediate navigation without // listening to the history directly. - this.unobserveHistory = this.props.history.listen((location) => { - this.setState((state) => ({ - previousLocation: state.currentLocation, - currentLocation: location, - })); - }); + this.unobserveHistory = (this.props.history as History).listen( + (location, _action, affectedEntries) => { + this.setState({ + previousLocation: affectedEntries[0], + currentLocation: location, + }); + }, + ); } public componentWillUnmount() { |
