Skip to content

Commit

Permalink
Merge pull request #3442 from chimp1984/fix-vote-result-view-update
Browse files Browse the repository at this point in the history
Fix bug with not updating vote result table at vote result block
  • Loading branch information
ripcurlx authored Oct 23, 2019
2 parents 8b9415f + 94f33d2 commit e0f0cf3
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import bisq.core.dao.state.model.governance.CompensationProposal;
import bisq.core.dao.state.model.governance.ConfiscateBondProposal;
import bisq.core.dao.state.model.governance.Cycle;
import bisq.core.dao.state.model.governance.DaoPhase;
import bisq.core.dao.state.model.governance.DecryptedBallotsWithMerits;
import bisq.core.dao.state.model.governance.EvaluatedProposal;
import bisq.core.dao.state.model.governance.Proposal;
Expand Down Expand Up @@ -200,7 +201,10 @@ protected void activate() {
daoFacade.addBsqStateListener(this);
cyclesTableView.getSelectionModel().selectedItemProperty().addListener(selectedVoteResultListItemListener);

fillCycleList();
if (daoStateService.isParseBlockChainComplete()) {
fillCycleList();
}

exportButton.setOnAction(event -> {
JsonElement cyclesJsonArray = getVotingHistoryJson();
GUIUtil.exportJSON("voteResultsHistory.json", cyclesJsonArray, (Stage) root.getScene().getWindow());
Expand Down Expand Up @@ -234,6 +238,20 @@ protected void deactivate() {

@Override
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
int chainHeight = daoStateService.getChainHeight();
if (periodService.getFirstBlockOfPhase(chainHeight, DaoPhase.Phase.RESULT) == chainHeight) {
// We had set the cycle initially but at the vote result we want to update it with the actual result.
// We remove the empty cycle to make space for the one with the result.
Optional<Cycle> optionalCurrentCycle = cyclesAdded.stream()
.filter(cycle -> cycle.isInCycle(chainHeight))
.findAny();
optionalCurrentCycle.ifPresent(cyclesAdded::remove);
Optional<CycleListItem> optionalCurrentCycleListItem = cycleListItemList.stream()
.filter(cycleListItem -> cycleListItem.getResultsOfCycle().getCycle().isInCycle(chainHeight))
.findAny();
optionalCurrentCycleListItem.ifPresent(cycleListItemList::remove);
}

fillCycleList();
}

Expand Down Expand Up @@ -351,8 +369,10 @@ private void onSelectProposalResultListItem(ProposalListItem item) {
}
}

private void showProposalResultWindow(EvaluatedProposal evaluatedProposal, Ballot ballot,
boolean isVoteIncludedInResult, SortedList<VoteListItem> sortedVoteListItemList) {
private void showProposalResultWindow(EvaluatedProposal evaluatedProposal,
Ballot ballot,
boolean isVoteIncludedInResult,
SortedList<VoteListItem> sortedVoteListItemList) {
proposalResultsWindow.show(evaluatedProposal, ballot, isVoteIncludedInResult, sortedVoteListItemList);
}

Expand Down

0 comments on commit e0f0cf3

Please sign in to comment.