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

Isolate core and presentational logics - Closes #611, #610, #584 #636

Merged
merged 27 commits into from
Aug 23, 2017

Conversation

reyraa
Copy link
Contributor

@reyraa reyraa commented Aug 22, 2017

  • Creates a middleware to:
    • Gather account info
    • Make Api call and handle success/error situations.
    • dispatch new actions accordingly.
  • Removes all account information from store after logging out
  • Adds Redux Thunk:
    • Moves all Api calls from components leaving only a single action in them to be fired when required.
    • Covers all actions unit tests.
  • Creates the TransactionAdded middleware to centralise handling of pending transactions and subsequent alert dialog.

Closes #611
Closes #610
Closes #584

@reyraa reyraa self-assigned this Aug 22, 2017
dispatch(activePeerReset());
dispatch(transactionsReset());
dispatch({ type: actionTypes.accountLoggedOut });
};
Copy link
Contributor

@alepop alepop Aug 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each dispatch will handle view re-render. I recommend to using one action that will be handled in different reducers. like, handle logout in each of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll change it

import ForgedBlocks from './forgedBlocks';

class Forging extends React.Component {
loadStats(key, startMoment) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component do not have a state, better use the stateless one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I forgot to change it

Copy link
Contributor

@slaweet slaweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks very good.

I found just this small issue:

  • cannot introduced in this PR, but related to 'cleaning store after logout': actionTypes.activePeerReset should set peer state to { data: {}, status: {} } inestead of { data: null, status: null } because, else there is TypeError: Cannot read property 'online' of null when I log out and log back in.

wrapper.find('.username input').simulate('change', { target: { value: 'sample_username' } });
wrapper.find('.next-button').simulate('click');
expect(wrapper.find('.primary-button button').props().disabled).to.not.equal(true);
// TODO: this doesn't work for some reason
// expect(props.showSuccessAlert).to.have.been.calledWith();
expect(props.delegateRegistered).to.have.been.calledWith();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO comment above can be also removed

@@ -10,20 +9,31 @@ class Transactions extends React.Component {
constructor() {
super();
this.canLoadMore = true;
this.transactionsCount = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used

expect(dispatch).to.have.been.calledWith(forgingReset());
expect(dispatch).to.have.been.calledWith(activePeerReset());
expect(dispatch).to.have.been.calledWith(transactionsReset());
expect(dispatch).to.have.property('callCount', 4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also expect(dispatch).to.have.been.called.exactly(4);

@reyraa reyraa merged commit 917d0b1 into development Aug 23, 2017
@reyraa reyraa deleted the 611-add-thunk branch August 23, 2017 10:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants