summaryrefslogtreecommitdiffhomepage
path: root/app/app.js
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-02-21 20:04:59 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-02-21 20:04:59 +0000
commit177657c401b01f7facece15779768bff2ea95fab (patch)
tree3875114675c91362f715a7c14d91c0e44a4a6514 /app/app.js
parenta1ee22a025e637d28c9b4eea82f6d81519aad383 (diff)
downloadmullvadvpn-177657c401b01f7facece15779768bff2ea95fab.tar.xz
mullvadvpn-177657c401b01f7facece15779768bff2ea95fab.zip
- Handle app flow in app.js
- Wire up connect() to "Secure connection" button - Refactor code - Drop promises in Backend in favor of event based approach
Diffstat (limited to 'app/app.js')
-rw-r--r--app/app.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/app.js b/app/app.js
index a7c0aca8f3..f717dc87d0 100644
--- a/app/app.js
+++ b/app/app.js
@@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, hashHistory } from 'react-router';
-import { syncHistoryWithStore } from 'react-router-redux';
+import { syncHistoryWithStore, replace } from 'react-router-redux';
import { webFrame } from 'electron';
import routes from './routes';
import configureStore from './store';
@@ -67,6 +67,11 @@ backend.on(Backend.EventType.logging, (account) => {
backend.on(Backend.EventType.login, (account, error) => {
const status = error ? LoginState.failed : LoginState.ok;
store.dispatch(userActions.loginChange({ status, error }));
+
+ // redirect to main screen after delay
+ if(status === LoginState.ok) {
+ setTimeout(() => store.dispatch(replace('/connect')), 1000);
+ }
});
backend.on(Backend.EventType.logout, () => {
@@ -75,6 +80,9 @@ backend.on(Backend.EventType.logout, () => {
account: null,
error: null
}));
+
+ // return to login screen
+ store.dispatch(replace('/'));
});
// helper method for router to pass backend down the component tree