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

Move the Login logic to middlewares - Closes #596 #603

Merged
merged 9 commits into from
Aug 16, 2017

Conversation

reyraa
Copy link
Contributor

@reyraa reyraa commented Aug 15, 2017

Close #596

Copy link
Contributor

@alepop alepop left a comment

Choose a reason for hiding this comment

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

Looks good 👍

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.

Nice. The code looks some much more organized with middlewares :-)

Just the next vs dispatch issue.

return getAccount(activePeer, address).then(accountData =>
getDelegate(activePeer, publicKey)
.then((delegateData) => {
next(accountLoggedIn(Object.assign({}, accountData, accountBasics,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to call store.dispatch(...) than next(...). RIght now it's not a big difference, but once we have more middlewares it will be easier if each action goes through each middleware.
https://stackoverflow.com/questions/40444158/should-you-dispatch-or-call-next-multiple-times-inside-of-a-redux-middleware

next(accountLoggedIn(Object.assign({}, accountData, accountBasics,
{ delegate: delegateData.delegate, isDelegate: true })));
}).catch(() => {
next(accountLoggedIn(Object.assign({}, accountData, accountBasics,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

middleware(store)(next)(activePeerSetAction);
expect(next).to.have.been.calledWith();

accountApiMock.restore();
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 ok for now.
But for the future, I just discovered a more fault-tolerant and less verbose way to restore stubs, mocks, etc. - sinon-test https://www.npmjs.com/package/sinon-test

@reyraa reyraa merged commit 5d30348 into development Aug 16, 2017
@reyraa reyraa deleted the 596-login-middleware branch August 16, 2017 09:44
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.

4 participants