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

NTP: Improve differentiation between mediation and new arbitration #3414

Merged
merged 3 commits into from
Oct 16, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,20 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import java.util.concurrent.atomic.AtomicInteger;

import lombok.Getter;

public class SupportTicketsPresentation {
@Getter
private final StringProperty numOpenArbitrationTickets = new SimpleStringProperty();
@Getter
private final BooleanProperty showOpenArbitrationTicketsNotification = new SimpleBooleanProperty();

@Getter
private final StringProperty numOpenMediationTickets = new SimpleStringProperty();
@Getter
private final BooleanProperty showOpenMediationTicketsNotification = new SimpleBooleanProperty();

@Getter
private final StringProperty numOpenRefundTickets = new SimpleStringProperty();
@Getter
private final BooleanProperty showOpenRefundTicketsNotification = new SimpleBooleanProperty();

@Getter
private final StringProperty numOpenSupportTickets = new SimpleStringProperty();
@Getter
private final BooleanProperty showOpenSupportTicketsNotification = new SimpleBooleanProperty();

@org.jetbrains.annotations.NotNull
private final ArbitrationManager arbitrationManager;
@org.jetbrains.annotations.NotNull
private final MediationManager mediationManager;
private RefundManager refundManager;
@org.jetbrains.annotations.NotNull
private final RefundManager refundManager;

@Inject
public SupportTicketsPresentation(ArbitrationManager arbitrationManager,
Expand All @@ -72,22 +57,10 @@ public SupportTicketsPresentation(ArbitrationManager arbitrationManager,
}

private void onChange() {
AtomicInteger openArbitrationDisputes = new AtomicInteger(arbitrationManager.getNumOpenDisputes().get());
int arbitrationTickets = openArbitrationDisputes.get();
numOpenArbitrationTickets.set(String.valueOf(arbitrationTickets));
showOpenArbitrationTicketsNotification.set(arbitrationTickets > 0);

AtomicInteger openMediationDisputes = new AtomicInteger(mediationManager.getNumOpenDisputes().get());
int mediationTickets = openMediationDisputes.get();
numOpenMediationTickets.set(String.valueOf(mediationTickets));
showOpenMediationTicketsNotification.set(mediationTickets > 0);

AtomicInteger openRefundDisputes = new AtomicInteger(refundManager.getNumOpenDisputes().get());
int refundTickets = openRefundDisputes.get();
numOpenRefundTickets.set(String.valueOf(refundTickets));
showOpenRefundTicketsNotification.set(refundTickets > 0);
int supportTickets = arbitrationManager.getNumOpenDisputes().get() +
mediationManager.getNumOpenDisputes().get() +
refundManager.getNumOpenDisputes().get();

int supportTickets = arbitrationTickets + mediationTickets + refundTickets;
numOpenSupportTickets.set(String.valueOf(supportTickets));
showOpenSupportTicketsNotification.set(supportTickets > 0);
}
Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/bisq/core/support/dispute/DisputeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ public void addAndPersistChatMessage(ChatMessage message) {

protected abstract String getDisputeInfo(Dispute dispute);

protected abstract String getDisputeIntroForPeer(String disputeInfo);

protected abstract String getDisputeIntroForDisputeCreator(String disputeInfo);


///////////////////////////////////////////////////////////////////////////////////////////
// Delegates for disputeListService
Expand Down Expand Up @@ -365,9 +369,10 @@ public void sendOpenNewDisputeMessage(Dispute dispute,
Optional<Dispute> storedDisputeOptional = findDispute(dispute);
if (!storedDisputeOptional.isPresent() || reOpen) {
String disputeInfo = getDisputeInfo(dispute);
String disputeMessage = getDisputeIntroForDisputeCreator(disputeInfo);
String sysMsg = dispute.isSupportTicket() ?
Res.get("support.youOpenedTicket", disputeInfo, Version.VERSION)
: Res.get("support.youOpenedDispute", disputeInfo, Version.VERSION);
: disputeMessage;

String message = Res.get("support.systemMsg", sysMsg);
ChatMessage chatMessage = new ChatMessage(
Expand Down Expand Up @@ -493,9 +498,10 @@ private String sendPeerOpenedDisputeMessage(Dispute disputeFromOpener,
Optional<Dispute> storedDisputeOptional = findDispute(dispute);
if (!storedDisputeOptional.isPresent()) {
String disputeInfo = getDisputeInfo(dispute);
String disputeMessage = getDisputeIntroForPeer(disputeInfo);
String sysMsg = dispute.isSupportTicket() ?
Res.get("support.peerOpenedTicket", disputeInfo)
: Res.get("support.peerOpenedDispute", disputeInfo);
Res.get("support.peerOpenedTicket", disputeInfo, Version.VERSION)
: disputeMessage;
ChatMessage chatMessage = new ChatMessage(
getSupportType(),
dispute.getTradeId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

import bisq.common.Timer;
import bisq.common.UserThread;
import bisq.common.app.Version;
import bisq.common.crypto.PubKeyRing;

import org.bitcoinj.core.AddressFormatException;
Expand Down Expand Up @@ -152,6 +153,15 @@ protected String getDisputeInfo(Dispute dispute) {
return Res.get("support.initialInfo", role, role, link);
}

@Override
protected String getDisputeIntroForPeer(String disputeInfo) {
return Res.get("support.peerOpenedDispute", disputeInfo, Version.VERSION);
}

@Override
protected String getDisputeIntroForDisputeCreator(String disputeInfo) {
return Res.get("support.youOpenedDispute", disputeInfo, Version.VERSION);
}

///////////////////////////////////////////////////////////////////////////////////////////
// Message handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import bisq.common.Timer;
import bisq.common.UserThread;
import bisq.common.app.Version;
import bisq.common.crypto.PubKeyRing;
import bisq.common.handlers.ErrorMessageHandler;
import bisq.common.handlers.ResultHandler;
Expand Down Expand Up @@ -140,6 +141,15 @@ protected String getDisputeInfo(Dispute dispute) {
return Res.get("support.initialInfo", role, role, link);
}

@Override
protected String getDisputeIntroForPeer(String disputeInfo) {
return Res.get("support.peerOpenedDisputeForMediation", disputeInfo, Version.VERSION);
}

@Override
protected String getDisputeIntroForDisputeCreator(String disputeInfo) {
return Res.get("support.youOpenedDisputeForMediation", disputeInfo, Version.VERSION);
}

///////////////////////////////////////////////////////////////////////////////////////////
// Message handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import bisq.common.Timer;
import bisq.common.UserThread;
import bisq.common.app.Version;
import bisq.common.crypto.PubKeyRing;

import com.google.inject.Inject;
Expand Down Expand Up @@ -129,6 +130,15 @@ protected String getDisputeInfo(Dispute dispute) {
return Res.get("support.initialInfo", role, role, link);
}

@Override
protected String getDisputeIntroForPeer(String disputeInfo) {
return Res.get("support.peerOpenedDispute", disputeInfo, Version.VERSION);
}

@Override
protected String getDisputeIntroForDisputeCreator(String disputeInfo) {
return Res.get("support.youOpenedDispute", disputeInfo, Version.VERSION);
}

///////////////////////////////////////////////////////////////////////////////////////////
// Message handler
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ shared.save=Save
shared.onionAddress=Onion address
shared.supportTicket=support ticket
shared.dispute=dispute
shared.mediationCase=mediation case
shared.seller=seller
shared.buyer=buyer
shared.allEuroCountries=All Euro countries
Expand Down Expand Up @@ -994,8 +995,10 @@ You can read more about the dispute process at: {2}
support.systemMsg=System message: {0}
support.youOpenedTicket=You opened a request for support.\n\n{0}\n\nBisq version: {1}
support.youOpenedDispute=You opened a request for a dispute.\n\n{0}\n\nBisq version: {1}
support.peerOpenedTicket=Your trading peer has requested support due to technical problems.\n\n{0}
support.peerOpenedDispute=Your trading peer has requested a dispute.\n\n{0}
support.youOpenedDisputeForMediation=You asked for mediation.\n\n{0}\n\nBisq version: {1}
support.peerOpenedTicket=Your trading peer has requested support due to technical problems.\n\n{0}\n\nBisq version: {1}
support.peerOpenedDispute=Your trading peer has requested a dispute.\n\n{0}\n\nBisq version: {1}
support.peerOpenedDisputeForMediation=Your trading peer has asked for mediation.\n\n{0}\n\nBisq version: {1}
support.mediatorsDisputeSummary=System message:\nMediator''s dispute summary:\n{0}
support.mediatorsAddress=Mediator''s node address: {0}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesView;
import bisq.desktop.main.support.SupportView;
import bisq.desktop.main.support.dispute.client.DisputeClientView;
import bisq.desktop.main.support.dispute.client.arbitration.ArbitrationClientView;
import bisq.desktop.main.support.dispute.client.mediation.MediationClientView;
import bisq.desktop.main.support.dispute.client.refund.RefundClientView;

import bisq.core.locale.Res;
import bisq.core.support.dispute.mediation.MediationManager;
Expand Down Expand Up @@ -254,11 +254,10 @@ private void onDisputeStateChanged(Trade trade, Trade.DisputeState disputeState)
if (message != null) {
goToSupport(trade, message, false);
}
}
if (mediationManager.findOwnDispute(trade.getId()).isPresent()) {
} else if (mediationManager.findOwnDispute(trade.getId()).isPresent()) {
String disputeOrTicket = mediationManager.findOwnDispute(trade.getId()).get().isSupportTicket() ?
Res.get("shared.supportTicket") :
Res.get("shared.dispute");
Res.get("shared.mediationCase");
switch (disputeState) {
// TODO
case MEDIATION_REQUESTED:
Expand Down Expand Up @@ -286,7 +285,7 @@ private void goToSupport(Trade trade, String message, boolean isMediation) {
Notification notification = new Notification().disputeHeadLine(trade.getShortId()).message(message);
Class<? extends DisputeClientView> viewClass = isMediation ?
MediationClientView.class :
ArbitrationClientView.class;
RefundClientView.class;
if (navigation.getCurrentPath() != null && !navigation.getCurrentPath().contains(viewClass)) {
notification.actionButtonTextWithGoTo("navigation.support")
.onAction(() -> navigation.navigateTo(MainView.class, SupportView.class, viewClass))
Expand Down