summaryrefslogtreecommitdiffhomepage
path: root/app/components
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-08-07 13:00:02 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-08-08 16:25:34 +0200
commit3e63b2509962201cd25861dc752b2a404f1b614d (patch)
tree0b0e7ca4b54a94a54c9f4750ada7dde95daff064 /app/components
parent3e6a4de0a1682bbe51300f4bee4f84f2679a8c25 (diff)
downloadmullvadvpn-3e63b2509962201cd25861dc752b2a404f1b614d.tar.xz
mullvadvpn-3e63b2509962201cd25861dc752b2a404f1b614d.zip
Add WindowStateObserver
Diffstat (limited to 'app/components')
-rw-r--r--app/components/Account.js9
-rw-r--r--app/components/Connect.js9
-rw-r--r--app/components/Settings.js11
3 files changed, 27 insertions, 2 deletions
diff --git a/app/components/Account.js b/app/components/Account.js
index e7a39b68ed..700f33af2b 100644
--- a/app/components/Account.js
+++ b/app/components/Account.js
@@ -9,6 +9,7 @@ import SettingsHeader, { HeaderTitle } from './SettingsHeader';
import styles from './AccountStyles';
import Img from './Img';
import { formatAccount } from '../lib/formatters';
+import WindowStateObserver from '../lib/window-state-observer';
import type { AccountToken } from '../lib/daemon-rpc';
@@ -35,12 +36,16 @@ export default class Account extends Component<Props, State> {
};
_isMounted = false;
-
_copyTimer: ?TimeoutID;
+ _windowStateObserver = new WindowStateObserver();
componentDidMount() {
this._isMounted = true;
this._refreshAccountExpiry();
+
+ this._windowStateObserver.onShow = () => {
+ this._refreshAccountExpiry();
+ };
}
componentWillUnmount() {
@@ -49,6 +54,8 @@ export default class Account extends Component<Props, State> {
if (this._copyTimer) {
clearTimeout(this._copyTimer);
}
+
+ this._windowStateObserver.dispose();
}
onAccountTokenClick() {
diff --git a/app/components/Connect.js b/app/components/Connect.js
index 1a6e21599a..71ddb365f4 100644
--- a/app/components/Connect.js
+++ b/app/components/Connect.js
@@ -9,9 +9,9 @@ import * as AppButton from './AppButton';
import Img from './Img';
import Accordion from './Accordion';
import styles from './ConnectStyles';
-
import { NoCreditError, NoInternetError } from '../errors';
import Map from './Map';
+import WindowStateObserver from '../lib/window-state-observer';
import type { HeaderBarStyle } from './HeaderBar';
import type { ConnectionReduxState } from '../redux/connection/reducers';
@@ -41,6 +41,7 @@ export default class Connect extends Component<Props, State> {
};
_copyTimer: ?TimeoutID;
+ _windowStateObserver = new WindowStateObserver();
shouldComponentUpdate(nextProps: Props, nextState: State) {
const { connection: prevConnection, ...otherPrevProps } = this.props;
@@ -60,12 +61,18 @@ export default class Connect extends Component<Props, State> {
componentDidMount() {
this.props.updateAccountExpiry();
+
+ this._windowStateObserver.onShow = () => {
+ this.props.updateAccountExpiry();
+ };
}
componentWillUnmount() {
if (this._copyTimer) {
clearTimeout(this._copyTimer);
}
+
+ this._windowStateObserver.dispose();
}
render() {
diff --git a/app/components/Settings.js b/app/components/Settings.js
index c447940338..0ed45c7685 100644
--- a/app/components/Settings.js
+++ b/app/components/Settings.js
@@ -10,6 +10,7 @@ import SettingsHeader, { HeaderTitle } from './SettingsHeader';
import CustomScrollbars from './CustomScrollbars';
import styles from './SettingsStyles';
import Img from './Img';
+import WindowStateObserver from '../lib/window-state-observer';
import type { LoginState } from '../redux/account/reducers';
@@ -28,8 +29,18 @@ type Props = {
};
export default class Settings extends Component<Props> {
+ _windowStateObserver = new WindowStateObserver();
+
componentDidMount() {
this.props.updateAccountExpiry();
+
+ this._windowStateObserver.onShow = () => {
+ this.props.updateAccountExpiry();
+ };
+ }
+
+ componentWillUnmount() {
+ this._windowStateObserver.dispose();
}
render() {