summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-06-30 10:25:46 +0200
committerErik Larkö <erik@mullvad.net>2017-07-07 14:01:25 +0200
commit3ff9d25d2a0b4f68d192c0bf69e73160d24c127b (patch)
tree4f25ea90ceab0d7e6db6a7288f189d1b0cd9fc53
parent249a7bd02f3be3e3a5dc4925775cddd63da3cbae (diff)
downloadmullvadvpn-3ff9d25d2a0b4f68d192c0bf69e73160d24c127b.tar.xz
mullvadvpn-3ff9d25d2a0b4f68d192c0bf69e73160d24c127b.zip
Refactor app.js
-rw-r--r--app/app.js47
1 files changed, 29 insertions, 18 deletions
diff --git a/app/app.js b/app/app.js
index f0fa27e4f1..f829e4bd29 100644
--- a/app/app.js
+++ b/app/app.js
@@ -21,23 +21,22 @@ import type { TrayIconType } from './lib/tray-icon-manager';
const initialState = null;
const memoryHistory = createMemoryHistory();
const store = configureStore(initialState, memoryHistory);
-const backend = new Backend(store);
-// reset login state if user quit the app during login
-if((['logging in', 'failed']: Array<LoginState>).includes(store.getState().account.status)) {
- store.dispatch(accountActions.loginChange({
- status: 'none'
- }));
-}
+//////////////////////////////////////////////////////////////////////////
+// Backend
+//////////////////////////////////////////////////////////////////////////
+const backend = new Backend(store);
-// reset connection state if user quit the app when logging in
-if(store.getState().connection.status === 'logging in') {
- store.dispatch(connectionActions.connectionChange({
- status: 'disconnected'
- }));
-}
+ipcRenderer.on('backend-info', (_event, args) => {
+ backend.setLocation(args.addr);
+ backend.sync();
+});
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
// Tray icon
+//////////////////////////////////////////////////////////////////////////
/**
* Get tray icon type based on connection state
@@ -60,13 +59,25 @@ const updateTrayIcon = () => {
};
store.subscribe(updateTrayIcon);
-ipcRenderer.on('backend-info', (_event, args) => {
- backend.setLocation(args.addr);
- backend.sync();
-});
-
// force update tray
updateTrayIcon();
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+
+// reset login state if user quit the app during login
+if((['logging in', 'failed']: Array<LoginState>).includes(store.getState().account.status)) {
+ store.dispatch(accountActions.loginChange({
+ status: 'none'
+ }));
+}
+
+// reset connection state if user quit the app when logging in
+if(store.getState().connection.status === 'logging in') {
+ store.dispatch(connectionActions.connectionChange({
+ status: 'disconnected'
+ }));
+}
+
// disable smart pinch.
webFrame.setZoomLevelLimits(1, 1);