Skip to content

Commit

Permalink
Fix check for vote inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrrm committed Jun 18, 2019
1 parent 12e46f0 commit 8c278a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;

import javafx.geometry.Insets;

import lombok.Getter;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -78,13 +80,17 @@ public Label getMyVoteIcon() {
} else {
myVoteIcon = getIcon(AwesomeIcon.THUMBS_DOWN, "dao-rejected-icon");
}
if (!isMyBallotIncluded) {
Label notIncluded = FormBuilder.getIcon(AwesomeIcon.BAN_CIRCLE);
return new Label("", new HBox(10, new StackPane(myVoteIcon, notIncluded),
getIcon(AwesomeIcon.MINUS, "dao-ignored-icon")));
}
} else {
myVoteIcon = getIcon(AwesomeIcon.MINUS, "dao-ignored-icon");
}
if (!isMyBallotIncluded) {
Label notIncluded = FormBuilder.getIcon(AwesomeIcon.BAN_CIRCLE);
return new Label("", new HBox(10, new StackPane(myVoteIcon, notIncluded),
getIcon(AwesomeIcon.MINUS, "dao-ignored-icon")));
if (!isMyBallotIncluded) {
myVoteIcon.setPadding(new Insets(0, 0, 0, 25));
return myVoteIcon;
}
}
return myVoteIcon;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public class VoteResultView extends ActivatableView<GridPane, Void> implements D
private ChangeListener<CycleListItem> selectedVoteResultListItemListener;
private ResultsOfCycle resultsOfCycle;
private ProposalListItem selectedProposalListItem;
private boolean isVoteIncludedInResult;


///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -253,6 +254,18 @@ private void onResultsListItemSelected(CycleListItem item) {
if (item != null) {
resultsOfCycle = item.getResultsOfCycle();

// Check if my vote is included in result
isVoteIncludedInResult = false;
resultsOfCycle.getEvaluatedProposals().forEach(evProposal -> resultsOfCycle.getDecryptedVotesForCycle()
.forEach(decryptedBallotsWithMerits -> {
// Iterate through all included votes to see if any of those are ours
if (!isVoteIncludedInResult) {
isVoteIncludedInResult = bsqWalletService.isWalletTransaction(decryptedBallotsWithMerits
.getVoteRevealTxId()).isPresent();
}
}));


maybeShowVoteResultErrors(item.getResultsOfCycle().getCycle());
createProposalsTable();

Expand Down Expand Up @@ -327,10 +340,6 @@ private void onSelectProposalResultListItem(ProposalListItem item) {
.findAny();

Ballot ballot = optionalBallot.orElse(null);
// Check if my vote is included in result
boolean isVoteIncludedInResult = voteListItemList.stream()
.anyMatch(voteListItem -> bsqWalletService.getTransaction(voteListItem.getBlindVoteTxId()) != null);

voteListItemList.clear();
resultsOfCycle.getEvaluatedProposals().stream()
.filter(evProposal -> evProposal.getProposal().equals(selectedProposalListItem.getEvaluatedProposal().getProposal()))
Expand Down Expand Up @@ -460,9 +469,7 @@ private void createProposalsTable() {
})
.map(evaluatedProposal -> new ProposalListItem(evaluatedProposal,
ballotByProposalTxIdMap.get(evaluatedProposal.getProposalTxId()),
voteListItemList.stream()
.anyMatch(voteListItem ->
bsqWalletService.getTransaction(voteListItem.getBlindVoteTxId()) != null),
isVoteIncludedInResult,
bsqFormatter))
.collect(Collectors.toList()));
GUIUtil.setFitToRowsForTableView(proposalsTableView, 25, 28, 6, 6);
Expand Down

0 comments on commit 8c278a6

Please sign in to comment.