From 94f33d2a07ae55eefc9099d14fd177743a5e3e80 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Tue, 22 Oct 2019 20:57:47 -0500 Subject: [PATCH] Fix bug with not updating vote result table at vote result block --- .../dao/governance/result/VoteResultView.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java index ee3f1ad6ad5..8b650004e17 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java @@ -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; @@ -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()); @@ -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 optionalCurrentCycle = cyclesAdded.stream() + .filter(cycle -> cycle.isInCycle(chainHeight)) + .findAny(); + optionalCurrentCycle.ifPresent(cyclesAdded::remove); + Optional optionalCurrentCycleListItem = cycleListItemList.stream() + .filter(cycleListItem -> cycleListItem.getResultsOfCycle().getCycle().isInCycle(chainHeight)) + .findAny(); + optionalCurrentCycleListItem.ifPresent(cycleListItemList::remove); + } + fillCycleList(); } @@ -351,8 +369,10 @@ private void onSelectProposalResultListItem(ProposalListItem item) { } } - private void showProposalResultWindow(EvaluatedProposal evaluatedProposal, Ballot ballot, - boolean isVoteIncludedInResult, SortedList sortedVoteListItemList) { + private void showProposalResultWindow(EvaluatedProposal evaluatedProposal, + Ballot ballot, + boolean isVoteIncludedInResult, + SortedList sortedVoteListItemList) { proposalResultsWindow.show(evaluatedProposal, ballot, isVoteIncludedInResult, sortedVoteListItemList); }