diff options
| -rw-r--r-- | app/app.js | 6 | ||||
| -rw-r--r-- | app/components/Connect.js | 5 | ||||
| -rw-r--r-- | app/components/Login.js | 14 | ||||
| -rw-r--r-- | app/lib/backend.js | 4 | ||||
| -rw-r--r-- | app/redux/account/reducers.js | 9 | ||||
| -rw-r--r-- | app/redux/connection/reducers.js | 11 |
6 files changed, 25 insertions, 24 deletions
diff --git a/app/app.js b/app/app.js index 1e56830880..f0fa27e4f1 100644 --- a/app/app.js +++ b/app/app.js @@ -24,14 +24,14 @@ const store = configureStore(initialState, memoryHistory); const backend = new Backend(store); // reset login state if user quit the app during login -if((['connecting', 'failed']: Array<LoginState>).includes(store.getState().account.status)) { +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 connecting -if(store.getState().connection.status === 'connecting') { +// reset connection state if user quit the app when logging in +if(store.getState().connection.status === 'logging in') { store.dispatch(connectionActions.connectionChange({ status: 'disconnected' })); diff --git a/app/components/Connect.js b/app/components/Connect.js index edca72c102..eb93d97432 100644 --- a/app/components/Connect.js +++ b/app/components/Connect.js @@ -1,4 +1,5 @@ // @flow + import moment from 'moment'; import React, { Component } from 'react'; import { If, Then, Else } from 'react-if'; @@ -128,7 +129,7 @@ export default class Connect extends Component { const displayLocation = this.displayLocation(); const mapBounds = this.calculateMapBounds(displayLocation.location, altitude); const mapBoundsOptions = { offset: [0, -113], animate: !this.state.isFirstPass }; - const accountLocation = this.convertToMapCoordinate(this.props.account.location || [0, 0]); + const accountLocation = this.convertToMapCoordinate(this.props.connection.location || [0, 0]); const serverLocation = this.convertToMapCoordinate(serverInfo.location); const map = process.platform === 'darwin' @@ -396,7 +397,7 @@ export default class Connect extends Component { displayLocation(): DisplayLocation { // return user location when disconnected if(this.props.connection.status === 'disconnected') { - let { location, country, city } = this.props.account; + let { location, country, city } = this.props.connection; return { location: location || [0, 0], country, city diff --git a/app/components/Login.js b/app/components/Login.js index 0427832973..e09df8c3c7 100644 --- a/app/components/Login.js +++ b/app/components/Login.js @@ -45,7 +45,7 @@ export default class Login extends Component { formTitle(s: LoginState): string { switch(s) { - case 'connecting': return 'Logging in...'; + case 'logging in': return 'Logging in...'; case 'failed': return 'Login failed'; case 'ok': return 'Login successful'; default: return 'Login'; @@ -55,7 +55,7 @@ export default class Login extends Component { formSubtitle(s: LoginState, e: ?Error): string { switch(s) { case 'failed': return (e && e.message) || 'Unknown error'; - case 'connecting': return 'Checking account number'; + case 'logging in': return 'Checking account number'; default: return 'Enter your account number'; } } @@ -68,7 +68,7 @@ export default class Login extends Component { } switch(s) { - case 'connecting': + case 'logging in': classes.push('login-form__input-wrap--inactive'); break; case 'failed': @@ -83,7 +83,7 @@ export default class Login extends Component { const classes = ['login-footer']; switch(s) { case 'ok': - case 'connecting': + case 'logging in': classes.push('login-footer--invisible'); break; } @@ -97,7 +97,7 @@ export default class Login extends Component { classes.push('login-form__submit--active'); } - if(s === 'connecting') { + if(s === 'logging in') { classes.push('login-form__submit--invisible'); } @@ -122,7 +122,7 @@ export default class Login extends Component { let isFailed = false; let isLoggedIn = false; switch(status) { - case 'connecting': isConnecting = true; break; + case 'logging in': isConnecting = true; break; case 'failed': isFailed = true; break; case 'ok': isLoggedIn = true; break; } @@ -143,7 +143,7 @@ export default class Login extends Component { <Container> <div className="login"> <div className="login-form"> - { /* show spinner when connecting */ } + { /* show spinner when logging in */ } <If condition={ isConnecting }> <Then> <div className="login-form__status-icon"> diff --git a/app/lib/backend.js b/app/lib/backend.js index 9c5b2ed064..a8774dc599 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -108,7 +108,7 @@ export class Backend { country: location.country, city: location.city }; - this._store.dispatch(accountActions.loginChange(newLocation)); + this._store.dispatch(connectionActions.connectionChange(newLocation)); }) .catch(e => { log.info('Failed getting new location', e); @@ -149,7 +149,7 @@ export class Backend { this._store.dispatch(accountActions.loginChange({ accountNumber: accountNumber, - status: 'connecting', + status: 'logging in', error: null, })); diff --git a/app/redux/account/reducers.js b/app/redux/account/reducers.js index 06dfb05941..b93a5b6948 100644 --- a/app/redux/account/reducers.js +++ b/app/redux/account/reducers.js @@ -2,17 +2,13 @@ import { handleActions } from 'redux-actions'; import actions from './actions.js'; -import type { Coordinate2d } from '../../types'; import type { ReduxAction } from '../store'; import type { BackendError } from '../../lib/backend'; -export type LoginState = 'none' | 'connecting' | 'failed' | 'ok'; +export type LoginState = 'none' | 'logging in' | 'failed' | 'ok'; export type AccountReduxState = { accountNumber: ?string, paidUntil: ?string, // ISO8601 - location: ?Coordinate2d, - country: ?string, - city: ?string, status: LoginState, error: ?BackendError }; @@ -20,9 +16,6 @@ export type AccountReduxState = { const initialState: AccountReduxState = { accountNumber: null, paidUntil: null, - location: null, - country: null, - city: null, status: 'none', error: null }; diff --git a/app/redux/connection/reducers.js b/app/redux/connection/reducers.js index bf44281602..daf746c034 100644 --- a/app/redux/connection/reducers.js +++ b/app/redux/connection/reducers.js @@ -3,20 +3,27 @@ import { handleActions } from 'redux-actions'; import actions from './actions'; import type { ReduxAction } from '../store'; +import type { Coordinate2d } from '../../types'; export type ConnectionState = 'disconnected' | 'connecting' | 'connected'; export type ConnectionReduxState = { status: ConnectionState, isOnline: boolean, serverAddress: ?string, - clientIp: ?string + clientIp: ?string, + location: ?Coordinate2d, + country: ?string, + city: ?string, }; const initialState: ConnectionReduxState = { status: 'disconnected', isOnline: true, serverAddress: null, - clientIp: null + clientIp: null, + location: null, + country: null, + city: null, }; export default handleActions({ |
