From 0139a51b57a2a7f0e18c17e1e4b3afcc1ccb1bab Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Sun, 29 Mar 2020 20:43:30 -0500 Subject: [PATCH] Replace the Get Support with Open Trader Chat until trade period is over Showing an `Open Trader Chat` button until the trade period is over will reduce the number of unnecessary support tickets and encourage trader-to-trader dialogue. If the trade timer expires without completing the button changes (as before) to open a mediation ticket. Implementation of this feature requires the button in TradeStepView to notify its parent TradeSubView which in turn notify its parent PendingTradesView that trader chat is to be opened. Basically a callback interface is passed two levels down the GUI hierarchy. Fixes #3801 --- .../resources/i18n/displayStrings.properties | 2 +- .../pendingtrades/PendingTradesView.java | 11 +++++++- .../pendingtrades/TradeStepInfo.java | 2 +- .../portfolio/pendingtrades/TradeSubView.java | 19 ++++++++++++- .../pendingtrades/steps/TradeStepView.java | 27 +++++++++++++++---- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 6b5d131672f..11b8d5b4e11 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -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? diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java index 1fa685f9049..4f896caf334 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java @@ -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(); @@ -764,5 +769,9 @@ private void update(Trade trade, JFXBadge badge) { }); return chatColumn; } -} + public interface ChatCallback { + void onOpenChat(Trade trade); + } + +} diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeStepInfo.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeStepInfo.java index 1b3f1f1c349..61508824984 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeStepInfo.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeStepInfo.java @@ -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); diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java index 84b6b81aa7b..8f0f9d76aee 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/TradeSubView.java @@ -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; @@ -56,6 +57,7 @@ public abstract class TradeSubView extends HBox { private TitledGroupBg tradeProcessTitledGroupBg; private int leftGridPaneRowIndex = 0; Subscription viewStateSubscription; + private PendingTradesView.ChatCallback chatCallback; /////////////////////////////////////////////////////////////////////////////////////////// @@ -144,6 +146,13 @@ private void createAndAddTradeStepView(Class 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()); @@ -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; + } +} + diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java index ef82e67448d..b277e58cce7 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java @@ -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; @@ -94,6 +95,7 @@ public abstract class TradeStepView extends AnchorPane { protected Label infoLabel; private Popup acceptMediationResultPopup; private BootstrapListener bootstrapListener; + private TradeSubView.ChatCallback chatCallback; /////////////////////////////////////////////////////////////////////////////////////////// @@ -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(); + } }); } @@ -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(); @@ -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; } @@ -654,4 +667,8 @@ private GridPane createInfoPopover() { return infoGridPane; } + + public void setChatCallback(TradeSubView.ChatCallback chatCallback) { + this.chatCallback = chatCallback; + } }