diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-06-11 15:38:27 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-06-12 15:58:20 +0200 |
| commit | 34219a223e87508817a5fd2fe93c1e013472a1ca (patch) | |
| tree | cdd88dbbdb5ffc42bc7202dba44b23020d855265 /app/components | |
| parent | fe3e41f0b5c95e50736565f1faaa212460fb7051 (diff) | |
| download | mullvadvpn-34219a223e87508817a5fd2fe93c1e013472a1ca.tar.xz mullvadvpn-34219a223e87508817a5fd2fe93c1e013472a1ca.zip | |
Refresh account expiration when window becomes visible
Diffstat (limited to 'app/components')
| -rw-r--r-- | app/components/Account.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/components/Account.js b/app/components/Account.js index 74c7d99629..8639d0fe42 100644 --- a/app/components/Account.js +++ b/app/components/Account.js @@ -7,6 +7,7 @@ import { Layout, Container } from './Layout'; import styles from './AccountStyles'; import Img from './Img'; import { formatAccount } from '../lib/formatters'; +import AppVisiblityObserver from '../lib/app-visibility'; import type { AccountToken } from '../lib/ipc-facade'; @@ -28,15 +29,27 @@ export default class Account extends Component<AccountProps, AccountState> { isRefreshingExpiry: false, }; + _appVisibilityObserver: ?AppVisiblityObserver; + _isMounted = false; componentDidMount() { this._isMounted = true; this._refreshAccountExpiry(); + + this._appVisibilityObserver = new AppVisiblityObserver((isVisible) => { + if (isVisible) { + this._refreshAccountExpiry(); + } + }); } componentWillUnmount() { this._isMounted = false; + + if (this._appVisibilityObserver) { + this._appVisibilityObserver.dispose(); + } } render() { |
