diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2019-05-14 00:16:09 +0800 |
---|---|---|
committer | Dan J Miller <danjm.com@gmail.com> | 2019-05-14 00:16:09 +0800 |
commit | 28c4001f5269eb170f14bd2829698ee402b2cfbf (patch) | |
tree | a9cb1fbf6fbbb2304c0d3224c1856e70a1fc69e5 /ui | |
parent | 08e8fb21dc142ab21184c1125f55b9f3e0ce6412 (diff) | |
download | tangerine-wallet-browser-28c4001f5269eb170f14bd2829698ee402b2cfbf.tar tangerine-wallet-browser-28c4001f5269eb170f14bd2829698ee402b2cfbf.tar.gz tangerine-wallet-browser-28c4001f5269eb170f14bd2829698ee402b2cfbf.tar.bz2 tangerine-wallet-browser-28c4001f5269eb170f14bd2829698ee402b2cfbf.tar.lz tangerine-wallet-browser-28c4001f5269eb170f14bd2829698ee402b2cfbf.tar.xz tangerine-wallet-browser-28c4001f5269eb170f14bd2829698ee402b2cfbf.tar.zst tangerine-wallet-browser-28c4001f5269eb170f14bd2829698ee402b2cfbf.zip |
Update auto-logout to recognize idle time in background (#6593)
* Fix wording of autoLogoutTimeLimitDescription
* AppStateController and update auto-logout functionality
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/pages/routes/index.js | 17 | ||||
-rw-r--r-- | ui/app/store/actions.js | 14 |
2 files changed, 19 insertions, 12 deletions
diff --git a/ui/app/pages/routes/index.js b/ui/app/pages/routes/index.js index 9c30da086..9eeac2da2 100644 --- a/ui/app/pages/routes/index.js +++ b/ui/app/pages/routes/index.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import { connect } from 'react-redux' import { Route, Switch, withRouter, matchPath } from 'react-router-dom' import { compose } from 'recompose' -import actions, {hideSidebar, hideWarning, lockMetamask} from '../../store/actions' +import actions from '../../store/actions' import log from 'loglevel' import IdleTimer from 'react-idle-timer' import {getMetaMaskAccounts, getNetworkIdentifier, preferencesSelector} from '../../selectors/selectors' @@ -99,7 +99,7 @@ class Routes extends Component { } renderRoutes () { - const { autoLogoutTimeLimit, lockMetamask } = this.props + const { autoLogoutTimeLimit, setLastActiveTime } = this.props const routes = ( <Switch> @@ -122,10 +122,7 @@ class Routes extends Component { if (autoLogoutTimeLimit > 0) { return ( - <IdleTimer - onIdle={lockMetamask} - timeout={autoLogoutTimeLimit * 1000 * 60} - > + <IdleTimer onAction={setLastActiveTime} throttle={1000}> {routes} </IdleTimer> ) @@ -338,7 +335,7 @@ Routes.propTypes = { networkDropdownOpen: PropTypes.bool, showNetworkDropdown: PropTypes.func, hideNetworkDropdown: PropTypes.func, - lockMetamask: PropTypes.func, + setLastActiveTime: PropTypes.func, history: PropTypes.object, location: PropTypes.object, dispatch: PropTypes.func, @@ -447,11 +444,7 @@ function mapDispatchToProps (dispatch) { setCurrentCurrencyToUSD: () => dispatch(actions.setCurrentCurrency('usd')), toggleAccountMenu: () => dispatch(actions.toggleAccountMenu()), setMouseUserState: (isMouseUser) => dispatch(actions.setMouseUserState(isMouseUser)), - lockMetamask: () => { - dispatch(lockMetamask()) - dispatch(hideWarning()) - dispatch(hideSidebar()) - }, + setLastActiveTime: () => dispatch(actions.setLastActiveTime()), } } diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 7d45f0932..7f6cbea1f 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -356,6 +356,10 @@ var actions = { setSelectedSettingsRpcUrl, SET_NETWORKS_TAB_ADD_MODE: 'SET_NETWORKS_TAB_ADD_MODE', setNetworksTabAddMode, + + // AppStateController-related actions + SET_LAST_ACTIVE_TIME: 'SET_LAST_ACTIVE_TIME', + setLastActiveTime, } module.exports = actions @@ -2760,3 +2764,13 @@ function setNetworksTabAddMode (isInAddMode) { value: isInAddMode, } } + +function setLastActiveTime () { + return (dispatch) => { + background.setLastActiveTime((err) => { + if (err) { + return dispatch(actions.displayWarning(err.message)) + } + }) + } +} |