Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Moving files and update account on login
Browse files Browse the repository at this point in the history
  • Loading branch information
Gina Contrino committed Oct 26, 2017
1 parent 2a1a7d3 commit 31284a7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/store/middlewares/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/store/middlewares/socket.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/store/middlewares/socket.test.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/socket.js → src/utils/api/socket.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/socket.test.js → src/utils/api/socket.test.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down

0 comments on commit 31284a7

Please sign in to comment.