diff --git a/src/store/middlewares/account.js b/src/store/middlewares/account.js index 412502aad..63e1a49c9 100644 --- a/src/store/middlewares/account.js +++ b/src/store/middlewares/account.js @@ -110,6 +110,9 @@ const checkTransactionAndUpdateAccount = (store, action) => { const accountMiddleware = store => next => (action) => { next(action); switch (action.type) { + case actionTypes.accountLoggedIn: + updateAccountData(store, action); + break; case actionTypes.newBlockCreated: checkTransactionAndUpdateAccount(store, action); break; diff --git a/src/store/middlewares/socket.js b/src/store/middlewares/socket.js index 0848600a3..bba9c4c77 100644 --- a/src/store/middlewares/socket.js +++ b/src/store/middlewares/socket.js @@ -1,5 +1,5 @@ import actionTypes from '../../constants/actions'; -import { socketSetup, closeConnection } from '../../utils/socket'; +import { socketSetup, closeConnection } from '../../utils/api/socket'; const socketMiddleware = store => ( next => (action) => { diff --git a/src/store/middlewares/socket.test.js b/src/store/middlewares/socket.test.js index 6236cb8fb..288ddcce8 100644 --- a/src/store/middlewares/socket.test.js +++ b/src/store/middlewares/socket.test.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spy, stub } from 'sinon'; import middleware from './socket'; -import * as socket from '../../utils/socket'; +import * as socket from '../../utils/api/socket'; import actionTypes from '../../constants/actions'; describe('Socket middleware', () => { diff --git a/src/utils/socket.js b/src/utils/api/socket.js similarity index 68% rename from src/utils/socket.js rename to src/utils/api/socket.js index 5b3113049..3a3f882bc 100644 --- a/src/utils/socket.js +++ b/src/utils/api/socket.js @@ -1,7 +1,7 @@ -import io from './socketShim'; -import { activePeerUpdate } from './../actions/peers'; -import actionTypes from './../constants/actions'; -import { SYNC_ACTIVE_INTERVAL, SYNC_INACTIVE_INTERVAL } from './../constants/api'; +import io from '../socketShim'; +import { activePeerUpdate } from '../../actions/peers'; +import actionTypes from '../../constants/actions'; +import { SYNC_ACTIVE_INTERVAL, SYNC_INACTIVE_INTERVAL } from '../../constants/api'; let connection; @@ -12,7 +12,7 @@ export const socketSetup = (store) => { ipc.on('blur', () => { interval = SYNC_INACTIVE_INTERVAL; }); ipc.on('focus', () => { interval = SYNC_ACTIVE_INTERVAL; }); } - connection = io.connect(`ws://${store.getState().peers.data.options.address}`); + connection = io.connect(`ws://${store.getState().peers.data.currentPeer}:${store.getState().peers.data.port}`); connection.on('blocks/change', (block) => { store.dispatch({ type: actionTypes.newBlockCreated, diff --git a/src/utils/socket.test.js b/src/utils/api/socket.test.js similarity index 93% rename from src/utils/socket.test.js rename to src/utils/api/socket.test.js index a455e7f5f..e8da13ea5 100644 --- a/src/utils/socket.test.js +++ b/src/utils/api/socket.test.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; import { spy } from 'sinon'; -import io from './socketShim'; -import actionTypes from './../constants/actions'; -import { SYNC_ACTIVE_INTERVAL, SYNC_INACTIVE_INTERVAL } from './../constants/api'; +import io from '../socketShim'; +import actionTypes from '../../constants/actions'; +import { SYNC_ACTIVE_INTERVAL, SYNC_INACTIVE_INTERVAL } from '../../constants/api'; import { socketSetup } from './socket'; describe('Socket', () => {