Skip to content

Commit

Permalink
Merge pull request #4099 from jmacxx/fix_getsupport_traderchat
Browse files Browse the repository at this point in the history
Replace the Get Support button with Open Trader Chat until trade period is over
  • Loading branch information
ripcurlx authored Apr 10, 2020
2 parents 34734c6 + 0139a51 commit edc4df1
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ portfolio.pending.support.text.getHelp=If you have any problems you can try to c
portfolio.pending.support.text.getHelp.arbitrator=If you have any problems you can try to contact the trade peer in the trade \
chat or ask the Bisq community at https://bisq.community. \
If your issue still isn't resolved, you can request more help from an arbitrator.
portfolio.pending.support.button.getHelp=Get support
portfolio.pending.support.button.getHelp=Open Trader Chat
portfolio.pending.support.popup.info=If your issue with the trade remains unsolved, you can open a support \
ticket to request help from a mediator. If you have not received the payment, please wait until the trade period is over.\n\n\
Are you sure you want to open a support ticket?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ protected void activate() {
root.getChildren().add(selectedSubView);
else if (root.getChildren().size() == 2)
root.getChildren().set(1, selectedSubView);

// create and register a callback so we can be notified when the subview
// wants to open the chat window
ChatCallback chatCallback = this::openChat;
selectedSubView.setChatCallback(chatCallback);
}

updateTableSelection();
Expand Down Expand Up @@ -764,5 +769,9 @@ private void update(Trade trade, JFXBadge badge) {
});
return chatColumn;
}
}

public interface ChatCallback {
void onOpenChat(Trade trade);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void setState(State state) {
// orange button
titledGroupBg.setText(Res.get("portfolio.pending.support.headline.halfPeriodOver"));
label.setText(firstHalfOverWarnTextSupplier.get());
button.setText(Res.get("portfolio.pending.openSupport").toUpperCase());
button.setText(Res.get("portfolio.pending.support.button.getHelp").toUpperCase());
button.setId(null);
button.getStyleClass().remove("action-button");
button.setDisable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import bisq.desktop.util.Layout;

import bisq.core.locale.Res;
import bisq.core.trade.Trade;

import javafx.scene.control.Label;
import javafx.scene.control.Separator;
Expand Down Expand Up @@ -56,6 +57,7 @@ public abstract class TradeSubView extends HBox {
private TitledGroupBg tradeProcessTitledGroupBg;
private int leftGridPaneRowIndex = 0;
Subscription viewStateSubscription;
private PendingTradesView.ChatCallback chatCallback;


///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -144,6 +146,13 @@ private void createAndAddTradeStepView(Class<? extends TradeStepView> viewClass)
tradeStepView = viewClass.getDeclaredConstructor(PendingTradesViewModel.class).newInstance(model);
contentPane.getChildren().setAll(tradeStepView);
tradeStepView.setTradeStepInfo(tradeStepInfo);
ChatCallback chatCallback = trade -> {
// call up the chain to open chat
if (this.chatCallback != null) {
this.chatCallback.onOpenChat(trade);
}
};
tradeStepView.setChatCallback(chatCallback);
tradeStepView.activate();
} catch (Exception e) {
log.error("Creating viewClass {} caused an error {}", viewClass, e.getMessage());
Expand All @@ -163,7 +172,15 @@ private void addContentPane() {
HBox.setHgrow(contentPane, Priority.SOMETIMES);
getChildren().add(contentPane);
}
}


public interface ChatCallback {
void onOpenChat(Trade trade);
}

public void setChatCallback(PendingTradesView.ChatCallback chatCallback) {
this.chatCallback = chatCallback;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
import bisq.desktop.main.portfolio.pendingtrades.TradeStepInfo;
import bisq.desktop.main.portfolio.pendingtrades.TradeSubView;
import bisq.desktop.util.Layout;

import bisq.core.locale.Res;
Expand Down Expand Up @@ -94,6 +95,7 @@ public abstract class TradeStepView extends AnchorPane {
protected Label infoLabel;
private Popup acceptMediationResultPopup;
private BootstrapListener bootstrapListener;
private TradeSubView.ChatCallback chatCallback;


///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -173,11 +175,11 @@ public void activate() {

if (!isMediationClosedState()) {
tradeStepInfo.setOnAction(e -> {
new Popup().attention(Res.get("portfolio.pending.support.popup.info"))
.actionButtonText(Res.get("portfolio.pending.support.popup.button"))
.onAction(this::openSupportTicket)
.closeButtonText(Res.get("shared.cancel"))
.show();
if (this.isTradePeriodOver()) {
openSupportTicket();
} else {
openChat();
}
});
}

Expand Down Expand Up @@ -228,6 +230,13 @@ private void openSupportTicket() {
model.dataModel.onOpenDispute();
}

private void openChat() {
// call up the chain to open chat
if (this.chatCallback != null) {
this.chatCallback.onOpenChat(this.trade);
}
}

public void deactivate() {
if (txIdSubscription != null)
txIdSubscription.unsubscribe();
Expand Down Expand Up @@ -500,6 +509,10 @@ private boolean isMediationClosedState() {
return trade.getDisputeState() == Trade.DisputeState.MEDIATION_CLOSED;
}

private boolean isTradePeriodOver() {
return Trade.TradePeriodState.TRADE_PERIOD_OVER == trade.tradePeriodStateProperty().get();
}

private boolean hasSelfAccepted() {
return trade.getProcessModel().getMediatedPayoutTxSignature() != null;
}
Expand Down Expand Up @@ -654,4 +667,8 @@ private GridPane createInfoPopover() {

return infoGridPane;
}

public void setChatCallback(TradeSubView.ChatCallback chatCallback) {
this.chatCallback = chatCallback;
}
}

0 comments on commit edc4df1

Please sign in to comment.