summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/components/Account.js15
-rw-r--r--app/lib/app-visibility.js28
-rw-r--r--app/main.js7
-rw-r--r--package.json2
-rw-r--r--yarn.lock18
5 files changed, 19 insertions, 51 deletions
diff --git a/app/components/Account.js b/app/components/Account.js
index 8639d0fe42..fc72ff5b30 100644
--- a/app/components/Account.js
+++ b/app/components/Account.js
@@ -1,13 +1,12 @@
// @flow
import moment from 'moment';
import * as React from 'react';
-import { Component, Text, View } from 'reactxp';
+import { Component, Text, View, App, Types } from 'reactxp';
import { Button, RedButton, GreenButton, Label } from './styled';
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';
@@ -29,7 +28,7 @@ export default class Account extends Component<AccountProps, AccountState> {
isRefreshingExpiry: false,
};
- _appVisibilityObserver: ?AppVisiblityObserver;
+ _activationStateToken: ?Types.SubscriptionToken;
_isMounted = false;
@@ -37,8 +36,8 @@ export default class Account extends Component<AccountProps, AccountState> {
this._isMounted = true;
this._refreshAccountExpiry();
- this._appVisibilityObserver = new AppVisiblityObserver((isVisible) => {
- if (isVisible) {
+ this._activationStateToken = App.activationStateChangedEvent.subscribe((activationState) => {
+ if (activationState === Types.AppActivationState.Active) {
this._refreshAccountExpiry();
}
});
@@ -47,8 +46,10 @@ export default class Account extends Component<AccountProps, AccountState> {
componentWillUnmount() {
this._isMounted = false;
- if (this._appVisibilityObserver) {
- this._appVisibilityObserver.dispose();
+ const activationStateToken = this._activationStateToken;
+ if (activationStateToken) {
+ activationStateToken.unsubscribe();
+ this._activationStateToken = null;
}
}
diff --git a/app/lib/app-visibility.js b/app/lib/app-visibility.js
deleted file mode 100644
index d599f6941b..0000000000
--- a/app/lib/app-visibility.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// @flow
-import { ipcRenderer } from 'electron';
-
-type EventHandler = (boolean) => any;
-
-export default class AppVisiblityObserver {
- _handler: EventHandler;
-
- constructor(handler: EventHandler) {
- this._handler = handler;
-
- ipcRenderer.on('show-window', this._handleShowEvent).on('hide-window', this._handleHideEvent);
- }
-
- dispose() {
- ipcRenderer
- .removeListener('show-window', this._handleShowEvent)
- .removeListener('hide-window', this._handleHideEvent);
- }
-
- _handleShowEvent = (_event) => {
- this._handler(true);
- };
-
- _handleHideEvent = (_event) => {
- this._handler(false);
- };
-}
diff --git a/app/main.js b/app/main.js
index 313c0f7cde..548605e6a1 100644
--- a/app/main.js
+++ b/app/main.js
@@ -112,7 +112,6 @@ const ApplicationMain = {
tray.on('click', () => windowController.toggle());
- this._registerWindowIpcEvents(window);
this._registerIpcListeners();
this._setAppMenu();
this._addContextMenu(window);
@@ -136,12 +135,6 @@ const ApplicationMain = {
window.loadFile('build/index.html');
},
- _registerWindowIpcEvents(window: BrowserWindow) {
- // Notify renderer when window visibility changes.
- window.on('show', () => window.webContents.send('show-window'));
- window.on('hide', () => window.webContents.send('hide-window'));
- },
-
_registerIpcListeners() {
ipcMain.on('on-browser-window-ready', () => {
this._pollConnectionInfoFile();
diff --git a/package.json b/package.json
index 7c8fd80de6..d6651459dc 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,7 @@
"react-router": "^4.2.0",
"react-router-redux": "^5.0.0-alpha.9",
"react-simple-maps": "^0.10.1",
- "reactxp": "1.3.0-rc.0",
+ "reactxp": "1.3.0-rc.6",
"redux": "^3.0.0",
"redux-thunk": "^2.2.0",
"uuid": "^3.0.1",
diff --git a/yarn.lock b/yarn.lock
index e7dc7c5380..fcac2a9476 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -109,6 +109,12 @@
"@types/node" "*"
"@types/react" "*"
+"@types/react-native@^0.55.23":
+ version "0.55.25"
+ resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.55.25.tgz#68484f8c3f1ab0ccce21ea556dcbcf20140f0c63"
+ dependencies:
+ "@types/react" "*"
+
"@types/react@*":
version "16.0.31"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.0.31.tgz#5285da62f3ac62b797f6d0729a1d6181f3180c3e"
@@ -4093,10 +4099,6 @@ iconv-lite@^0.4.23, iconv-lite@^0.4.4:
dependencies:
safer-buffer ">= 2.1.2 < 3"
-ifvisible@^1.1.0:
- version "1.1.0"
- resolved "https://registry.yarnpkg.com/ifvisible/-/ifvisible-1.1.0.tgz#a47768028c7c256368b16eaf3312e6898280215c"
-
ignore-walk@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8"
@@ -6334,15 +6336,15 @@ react@^16.0.0:
object-assign "^4.1.1"
prop-types "^15.6.0"
-reactxp@1.3.0-rc.0:
- version "1.3.0-rc.0"
- resolved "https://registry.yarnpkg.com/reactxp/-/reactxp-1.3.0-rc.0.tgz#13c59bbeb8d986db5f3fece0e3f0a421ea53f6ac"
+reactxp@1.3.0-rc.6:
+ version "1.3.0-rc.6"
+ resolved "https://registry.yarnpkg.com/reactxp/-/reactxp-1.3.0-rc.6.tgz#11e68d2e450926b7b51d507300041912eb3dfc61"
dependencies:
"@types/lodash" "^4.14.80"
"@types/react" "^16.3.17"
"@types/react-dom" "^16.0.6"
+ "@types/react-native" "^0.55.23"
assert "^1.3.0"
- ifvisible "^1.1.0"
lodash "^4.17.4"
prop-types "^15.5.9"
rebound "^0.1.0"