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

Isolate voting dialog - Closes #723 #748

Merged
merged 19 commits into from
Sep 19, 2017
Merged

Conversation

reyraa
Copy link
Contributor

@reyraa reyraa commented Sep 15, 2017

Replaces the lists of votes and unvotes with a dictionary including all votes together. This helps eliminate unnecessary iteration over delegates and vote lists to maintain vote status. also, stores the list of delegates and votes in redux store to isolate the voting component from votingDialog component.
to do so, this PR:

  • Updates voting actions
    • Adds votesFetched, delegatesFetched, voteToggled
    • removes removedFromVoteList and addedToVoteList
  • Refactors all components in voting and votingDialog to reflect the above changes.
  • Also moves Api calls from voting component to actions leaving the aforementioned component fully presentational.

Closes #723

@reyraa reyraa self-assigned this Sep 15, 2017
@reyraa reyraa added this to Pull Requests in Sprint Board 11-09-17 Sep 15, 2017
@slaweet slaweet added this to Pull Requests in Version 1.2.0 Sep 15, 2017
onEnter={this.loadMore.bind(this)}></Waypoint>
scrollableAncestor={window}
key={this.props.delegates.length}
onEnter={this.loadMore.bind(this)}></Waypoint>
Copy link
Contributor

Choose a reason for hiding this comment

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

loadMore function doesn't work when page scroller rich end of the page

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

I really like the redux part (actions, reducer). It's even cleaner and more concise than I thought I would be.

Though there is a bug if I do two votes in a row before the first one is processed. The state of votes is not updated correctly, just try it. Note that doing two votes in a row is very likely with the Launch protocol.

@@ -27,7 +27,7 @@ export const voteAutocomplete = (activePeer, username, votedList) => {
listDelegates(activePeer, options)
.then((response) => {
resolve(response.delegates.filter(delegate =>
votedList.filter(item => item.username === delegate.username).length === 0,
Object.keys(votedList).filter(item => item === delegate.username).length === 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename votedList since it is not a list anymore.

resolve(
Object.keys(votedList)
.filter(delegate => delegate.indexOf(username) !== -1)
.map(element => ({ username: element, publicKey: votedList[element].publicKey })));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename votedList since it is not a list anymore.

@@ -70,15 +70,19 @@ describe('Utils: Delegate', () => {

describe('unvoteAutocomplete', () => {
it('should return a promise', () => {
const votedList = ['genesis_1', 'genesis_2', 'genesis_3'];
const voteList = {
Copy link
Contributor

@slaweet slaweet Sep 18, 2017

Choose a reason for hiding this comment

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

Please rename voteList since it is not a list anymore.

Copy link
Contributor

@yasharAyari yasharAyari left a comment

Choose a reason for hiding this comment

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

good job.

@reyraa reyraa merged commit 0a544a0 into development Sep 19, 2017
@reyraa reyraa deleted the 723-isolate-voting-dialog branch September 19, 2017 08:05
@reyraa reyraa moved this from Pull Requests to Merged Pull Requests in Sprint Board 18-09-17 Sep 19, 2017
@reyraa reyraa moved this from Pull Requests to Merged Pull Requests in Version 1.2.0 Sep 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Sprint Board 18-09-17
Merged Pull Requests
Version 1.2.0
Merged Pull Requests
Development

Successfully merging this pull request may close these issues.

None yet

4 participants