summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-02-28 15:54:46 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-02-28 15:54:46 +0000
commit8acce108f61ff5d581ee765530ba2b90befd9e9d (patch)
treeb651d368ce5cd919a4f85659e84b96248a45723b /app
parent5d2ebe06a0cd9fc50942bc068c73f37cc298e0cc (diff)
downloadmullvadvpn-8acce108f61ff5d581ee765530ba2b90befd9e9d.tar.xz
mullvadvpn-8acce108f61ff5d581ee765530ba2b90befd9e9d.zip
Refactor code
Diffstat (limited to 'app')
-rw-r--r--app/app.js27
1 files changed, 12 insertions, 15 deletions
diff --git a/app/app.js b/app/app.js
index 9c600a3840..820236671f 100644
--- a/app/app.js
+++ b/app/app.js
@@ -9,13 +9,14 @@ import configureStore from './store';
import userActions from './actions/user';
import connectActions from './actions/connect';
import Backend from './lib/backend';
-import mapBackendEventsToReduxActions from './lib/backend-redux';
+import mapBackendEventsToReduxActions from './lib/backend-redux-actions';
import { LoginState, ConnectionState } from './constants';
const initialState = {};
const memoryHistory = createMemoryHistory();
const store = configureStore(initialState, memoryHistory);
const routes = makeRoutes(store);
+const backend = new Backend();
// reset login state if user quit the app during login
if([LoginState.connecting, LoginState.failed].includes(store.getState().user.status)) {
@@ -47,21 +48,16 @@ webFrame.setVisualZoomLevelLimits(1, 1);
// Tray icon
const updateTrayIcon = () => {
- const s = store.getState().connect.status;
- let iconName;
-
- if(s === ConnectionState.connected) {
- iconName = 'connected';
- } else {
- iconName = 'default';
- }
-
- ipcRenderer.send('changeTrayIcon', iconName);
+ const getName = (s) => {
+ switch(s) {
+ case ConnectionState.connected: return 'connected';
+ default: return 'default';
+ }
+ };
+ const { connect } = store.getState();
+ ipcRenderer.send('changeTrayIcon', getName(connect.status));
};
-// Create backend
-const backend = new Backend();
-
/**
* Patch backend state.
*
@@ -83,7 +79,8 @@ const syncBackendWithReduxStore = (backend, store) => {
default: return BS.disconnected;
}
};
- backend._connStatus = mapConnStatus(store.getState().connect.status);
+ const { connect } = store.getState();
+ backend._connStatus = mapConnStatus(connect.status);
};
syncBackendWithReduxStore(backend, store);