Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.2.0] Improve mediation result popup handling #3503

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ portfolio.pending.mediationResult.popup.info=The mediator has suggested the foll
More details about the new arbitration model:\n\
https://docs.bisq.network/trading-rules.html#arbitration
portfolio.pending.mediationResult.popup.openArbitration=Reject and request arbitration
portfolio.pending.mediationResult.popup.alreadyAccepted=You've already accepted

portfolio.closed.completed=Completed
portfolio.closed.ticketClosed=Arbitrated
Expand Down
25 changes: 20 additions & 5 deletions desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ protected enum Type {
private boolean showBusyAnimation;
protected boolean hideCloseButton;
protected boolean isDisplayed;
protected boolean disableActionButton;

@Getter
protected BooleanProperty isHiddenProperty = new SimpleBooleanProperty();
Expand Down Expand Up @@ -495,6 +496,12 @@ public T setHeadlineStyle(String headlineStyle) {
return (T) this;
}

public T disableActionButton() {
this.disableActionButton = true;
//noinspection unchecked
return (T) this;
}


///////////////////////////////////////////////////////////////////////////////////////////
// Protected
Expand Down Expand Up @@ -925,16 +932,24 @@ protected void addButtons() {

if (actionHandlerOptional.isPresent() || actionButtonText != null) {
actionButton = new AutoTooltipButton(actionButtonText == null ? Res.get("shared.ok") : actionButtonText);
actionButton.setDefaultButton(true);

if (!disableActionButton)
actionButton.setDefaultButton(true);
else
actionButton.setDisable(true);

HBox.setHgrow(actionButton, Priority.SOMETIMES);

actionButton.getStyleClass().add("action-button");
//TODO app wide focus
//actionButton.requestFocus();
actionButton.setOnAction(event -> {
hide();
actionHandlerOptional.ifPresent(Runnable::run);
});

if (!disableActionButton) {
actionButton.setOnAction(event -> {
hide();
actionHandlerOptional.ifPresent(Runnable::run);
});
}

buttonBox.setSpacing(10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void registerSubscriptions() {

mediationResultStateSubscription = EasyBind.subscribe(trade.mediationResultStateProperty(), newValue -> {
if (newValue != null) {
updateMediationResultState();
updateMediationResultState(true);
}
});

Expand Down Expand Up @@ -416,15 +416,15 @@ private void updateDisputeState(Trade.DisputeState disputeState) {
case MEDIATION_CLOSED:
if (tradeStepInfo != null) {
tradeStepInfo.setOnAction(e -> {
updateMediationResultState();
updateMediationResultState(false);
});
}

if (tradeStepInfo != null) {
tradeStepInfo.setState(TradeStepInfo.State.MEDIATION_RESULT);
}

updateMediationResultState();
updateMediationResultState(true);
break;
case REFUND_REQUESTED:
deactivatePaymentButtons(true);
Expand Down Expand Up @@ -459,7 +459,7 @@ private void updateDisputeState(Trade.DisputeState disputeState) {
}
}

private void updateMediationResultState() {
private void updateMediationResultState(boolean blockOpeningOfResultAcceptedPopup) {
if (isInArbitration()) {
if (isRefundRequestStartedByPeer()) {
tradeStepInfo.setState(TradeStepInfo.State.IN_REFUND_REQUEST_PEER_REQUESTED);
Expand All @@ -471,7 +471,8 @@ private void updateMediationResultState() {
// (e.g. we might receive a RECEIVED_SIG_MSG but then later a SIG_MSG_IN_MAILBOX).
if (hasSelfAccepted()) {
tradeStepInfo.setState(TradeStepInfo.State.MEDIATION_RESULT_SELF_ACCEPTED);
openMediationResultPopup(Res.get("portfolio.pending.mediationResult.popup.headline", trade.getShortId()));
if (!blockOpeningOfResultAcceptedPopup)
openMediationResultPopup(Res.get("portfolio.pending.mediationResult.popup.headline", trade.getShortId()));
} else if (peerAccepted()) {
tradeStepInfo.setState(TradeStepInfo.State.MEDIATION_RESULT_PEER_ACCEPTED);
if (acceptMediationResultPopup == null) {
Expand Down Expand Up @@ -535,14 +536,18 @@ private void openMediationResultPopup(String headLine) {
long lockTime = trade.getDelayedPayoutTx().getLockTime();
int bestChainHeight = model.dataModel.btcWalletService.getBestChainHeight();
long remaining = lockTime - bestChainHeight;

String actionButtonText = hasSelfAccepted() ?
Res.get("portfolio.pending.mediationResult.popup.alreadyAccepted") : Res.get("shared.accept");

acceptMediationResultPopup = new Popup<>().width(900)
.headLine(headLine)
.instruction(Res.get("portfolio.pending.mediationResult.popup.info",
myPayoutAmount,
peersPayoutAmount,
BSFormatter.getDateFromBlockHeight(remaining),
lockTime))
.actionButtonText(Res.get("shared.accept"))
.actionButtonText(actionButtonText)
.onAction(() -> {
model.dataModel.mediationManager.acceptMediationResult(trade,
() -> {
Expand All @@ -569,6 +574,10 @@ private void openMediationResultPopup(String headLine) {
acceptMediationResultPopup = null;
});

if (hasSelfAccepted()) {
acceptMediationResultPopup.disableActionButton();
}

acceptMediationResultPopup.show();
}

Expand Down