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

Replace the Get Support button with Open Trader Chat until trade period is over #4099

Merged
merged 1 commit into from Apr 10, 2020
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
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 @@ -796,7 +796,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;
}
}