diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-08-02 18:59:38 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-08-08 15:26:34 +0200 |
| commit | 2508acf0e4c9890e877512f7836f4edb4e4cdfe3 (patch) | |
| tree | 7566579199582f7590ade907e9fc45cce7811a77 /app | |
| parent | 0277922f4b4f1fa3cc93ed2dcdd2cc7022b2ad22 (diff) | |
| download | mullvadvpn-2508acf0e4c9890e877512f7836f4edb4e4cdfe3.tar.xz mullvadvpn-2508acf0e4c9890e877512f7836f4edb4e4cdfe3.zip | |
Use appropriate history methods when navigating between pages
Diffstat (limited to 'app')
| -rw-r--r-- | app/containers/AccountPage.js | 6 | ||||
| -rw-r--r-- | app/containers/AdvancedSettingsPage.js | 9 | ||||
| -rw-r--r-- | app/containers/ConnectPage.js | 4 | ||||
| -rw-r--r-- | app/containers/LoginPage.js | 4 | ||||
| -rw-r--r-- | app/containers/PreferencesPage.js | 8 | ||||
| -rw-r--r-- | app/containers/SelectLocationPage.js | 10 | ||||
| -rw-r--r-- | app/containers/SettingsPage.js | 14 | ||||
| -rw-r--r-- | app/containers/SupportPage.js | 6 |
8 files changed, 33 insertions, 28 deletions
diff --git a/app/containers/AccountPage.js b/app/containers/AccountPage.js index 078c893748..712466f191 100644 --- a/app/containers/AccountPage.js +++ b/app/containers/AccountPage.js @@ -3,7 +3,7 @@ import { remote } from 'electron'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { push } from 'connected-react-router'; +import { goBack } from 'connected-react-router'; import Account from '../components/Account'; import accountActions from '../redux/account/actions'; import { links } from '../config'; @@ -19,7 +19,7 @@ const mapStateToProps = (state: ReduxState) => ({ }); const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { const { copyAccountToken } = bindActionCreators(accountActions, dispatch); - const { push: pushHistory } = bindActionCreators({ push }, dispatch); + const history = bindActionCreators({ goBack }, dispatch); return { updateAccountExpiry: () => props.app.updateAccountExpiry(), onCopyAccountToken: () => copyAccountToken(), @@ -27,7 +27,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => props.app.logout(); }, onClose: () => { - pushHistory('/settings'); + history.goBack(); }, onBuyMore: () => openLink(links['purchase']), }; diff --git a/app/containers/AdvancedSettingsPage.js b/app/containers/AdvancedSettingsPage.js index 9f88228cc3..bf584096b9 100644 --- a/app/containers/AdvancedSettingsPage.js +++ b/app/containers/AdvancedSettingsPage.js @@ -1,7 +1,8 @@ // @flow import { connect } from 'react-redux'; -import { push } from 'connected-react-router'; +import { goBack } from 'connected-react-router'; +import { bindActionCreators } from 'redux'; import { AdvancedSettings } from '../components/AdvancedSettings'; import RelaySettingsBuilder from '../lib/relay-settings-builder'; import { log } from '../lib/platform'; @@ -26,9 +27,11 @@ const mapStateToProps = (state: ReduxState) => { }; const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { + const history = bindActionCreators({ goBack }, dispatch); return { - onClose: () => dispatch(push('/settings')), - + onClose: () => { + history.goBack(); + }, onUpdate: async (protocol, port) => { const relayUpdate = RelaySettingsBuilder.normal() .tunnel.openvpn((openvpn) => { diff --git a/app/containers/ConnectPage.js b/app/containers/ConnectPage.js index d1d11af334..0ad43e9c0b 100644 --- a/app/containers/ConnectPage.js +++ b/app/containers/ConnectPage.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { push as pushHistory } from 'connected-react-router'; +import { push } from 'connected-react-router'; import { links } from '../config'; import Connect from '../components/Connect'; import connectActions from '../redux/connection/actions'; @@ -56,7 +56,7 @@ const mapStateToProps = (state: ReduxState) => { const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { const { copyIPAddress } = bindActionCreators(connectActions, dispatch); - const history = bindActionCreators({ push: pushHistory }, dispatch); + const history = bindActionCreators({ push }, dispatch); return { onSettings: () => { diff --git a/app/containers/LoginPage.js b/app/containers/LoginPage.js index 74823f3925..539f05c5ac 100644 --- a/app/containers/LoginPage.js +++ b/app/containers/LoginPage.js @@ -21,11 +21,11 @@ const mapStateToProps = (state: ReduxState) => { }; }; const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { - const { push: pushHistory } = bindActionCreators({ push }, dispatch); + const history = bindActionCreators({ push }, dispatch); const { resetLoginError, updateAccountToken } = bindActionCreators(accountActions, dispatch); return { openSettings: () => { - pushHistory('/settings'); + history.push('/settings'); }, login: (account) => { props.app.login(account); diff --git a/app/containers/PreferencesPage.js b/app/containers/PreferencesPage.js index 8534a70d74..ee2709c767 100644 --- a/app/containers/PreferencesPage.js +++ b/app/containers/PreferencesPage.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { push } from 'connected-react-router'; +import { goBack } from 'connected-react-router'; import Preferences from '../components/Preferences'; import { log, getOpenAtLogin, setOpenAtLogin } from '../lib/platform'; @@ -15,9 +15,11 @@ const mapStateToProps = (state: ReduxState) => ({ }); const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { - const { push: pushHistory } = bindActionCreators({ push }, dispatch); + const history = bindActionCreators({ goBack }, dispatch); return { - onClose: () => pushHistory('/settings'), + onClose: () => { + history.goBack(); + }, getAutoStart: () => { return getOpenAtLogin(); }, diff --git a/app/containers/SelectLocationPage.js b/app/containers/SelectLocationPage.js index 6307e9421b..037dd67a0b 100644 --- a/app/containers/SelectLocationPage.js +++ b/app/containers/SelectLocationPage.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { push } from 'connected-react-router'; +import { goBack } from 'connected-react-router'; import SelectLocation from '../components/SelectLocation'; import RelaySettingsBuilder from '../lib/relay-settings-builder'; import { log } from '../lib/platform'; @@ -14,9 +14,9 @@ const mapStateToProps = (state: ReduxState) => ({ settings: state.settings, }); const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { - const { push: pushHistory } = bindActionCreators({ push }, dispatch); + const history = bindActionCreators({ goBack }, dispatch); return { - onClose: () => pushHistory('/connect'), + onClose: () => history.goBack(), onSelect: async (relayLocation) => { try { const relayUpdate = RelaySettingsBuilder.normal() @@ -27,9 +27,9 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => await props.app.fetchRelaySettings(); await props.app.connectTunnel(); - pushHistory('/connect'); + history.goBack(); } catch (e) { - log.error('Failed to select server: ', e.message); + log.error(`Failed to select server: ${e.message}`); } }, }; diff --git a/app/containers/SettingsPage.js b/app/containers/SettingsPage.js index f0e8d7c53b..06c0cd6060 100644 --- a/app/containers/SettingsPage.js +++ b/app/containers/SettingsPage.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { push } from 'connected-react-router'; +import { push, goBack } from 'connected-react-router'; import Settings from '../components/Settings'; import { links } from '../config'; import { getAppVersion, openLink, exit } from '../lib/platform'; @@ -16,14 +16,14 @@ const mapStateToProps = (state: ReduxState) => ({ appVersion: getAppVersion(), }); const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) => { - const { push: pushHistory } = bindActionCreators({ push }, dispatch); + const history = bindActionCreators({ push, goBack }, dispatch); return { onQuit: () => exit(), - onClose: () => pushHistory('/connect'), - onViewAccount: () => pushHistory('/settings/account'), - onViewSupport: () => pushHistory('/settings/support'), - onViewPreferences: () => pushHistory('/settings/preferences'), - onViewAdvancedSettings: () => pushHistory('/settings/advanced'), + onClose: () => history.goBack(), + onViewAccount: () => history.push('/settings/account'), + onViewSupport: () => history.push('/settings/support'), + onViewPreferences: () => history.push('/settings/preferences'), + onViewAdvancedSettings: () => history.push('/settings/advanced'), onExternalLink: (type) => openLink(links[type]), updateAccountExpiry: () => props.app.updateAccountExpiry(), }; diff --git a/app/containers/SupportPage.js b/app/containers/SupportPage.js index ffab2d2095..78d1b41ebe 100644 --- a/app/containers/SupportPage.js +++ b/app/containers/SupportPage.js @@ -1,7 +1,7 @@ // @flow import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { push } from 'connected-react-router'; +import { goBack } from 'connected-react-router'; import Support from '../components/Support'; import { openItem } from '../lib/platform'; import { collectProblemReport, sendProblemReport } from '../lib/problem-report'; @@ -18,10 +18,10 @@ const mapStateToProps = (state: ReduxState) => ({ const mapDispatchToProps = (dispatch: ReduxDispatch, _props: SharedRouteProps) => { const { saveReportForm, clearReportForm } = bindActionCreators(supportActions, dispatch); - const { push: pushHistory } = bindActionCreators({ push }, dispatch); + const history = bindActionCreators({ goBack }, dispatch); return { - onClose: () => pushHistory('/settings'), + onClose: () => history.goBack(), viewLog: (path) => openItem(path), saveReportForm, clearReportForm, |
