mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-09 07:02:24 -04:00
Add callback for broadcaster when sending mailbox msg
This commit is contained in:
parent
9bb4683379
commit
602c503cea
22 changed files with 231 additions and 112 deletions
|
@ -39,8 +39,11 @@ import io.bitsquare.gui.popups.DisplayAlertMessagePopup;
|
|||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.popups.WalletPasswordPopup;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.locale.CountryUtil;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.P2PServiceListener;
|
||||
import io.bitsquare.payment.OKPayAccount;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.trade.offer.OpenOffer;
|
||||
|
@ -411,6 +414,15 @@ public class MainViewModel implements ViewModel {
|
|||
|
||||
// now show app
|
||||
showAppScreen.set(true);
|
||||
|
||||
if (BitsquareApp.DEV_MODE && user.getPaymentAccounts().isEmpty()) {
|
||||
OKPayAccount okPayAccount = new OKPayAccount();
|
||||
okPayAccount.setAccountNr("dummy");
|
||||
okPayAccount.setAccountName("OKPay dummy");
|
||||
okPayAccount.setSelectedTradeCurrency(CurrencyUtil.getDefaultTradeCurrency());
|
||||
okPayAccount.setCountry(CountryUtil.getDefaultCountry());
|
||||
user.addPaymentAccount(okPayAccount);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPeriodicallyForBtcSyncState() {
|
||||
|
|
|
@ -26,6 +26,8 @@ import io.bitsquare.btc.TradeWalletService;
|
|||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.common.model.ActivatableDataModel;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
|
@ -54,6 +56,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class PendingTradesDataModel extends ActivatableDataModel {
|
||||
|
@ -152,10 +155,11 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
}
|
||||
}
|
||||
|
||||
void onFiatPaymentStarted() {
|
||||
void onFiatPaymentStarted(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
checkNotNull(trade, "trade must not be null");
|
||||
if (trade instanceof BuyerTrade && trade.getDisputeState() == Trade.DisputeState.NONE)
|
||||
((BuyerTrade) trade).onFiatPaymentStarted();
|
||||
checkArgument(trade instanceof BuyerTrade, "Check failed: trade instanceof BuyerTrade");
|
||||
checkArgument(trade.getDisputeState() == Trade.DisputeState.NONE, "Check failed: trade.getDisputeState() == Trade.DisputeState.NONE");
|
||||
((BuyerTrade) trade).onFiatPaymentStarted(resultHandler, errorMessageHandler);
|
||||
}
|
||||
|
||||
void onFiatPaymentReceived() {
|
||||
|
|
|
@ -131,7 +131,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||
appFocusProperty = scene.getWindow().focusedProperty();
|
||||
appFocusProperty.addListener(appFocusChangeListener);
|
||||
model.currentTrade().addListener(currentTradeChangeListener);
|
||||
setNewSubView(model.currentTrade().get());
|
||||
//setNewSubView(model.currentTrade().get());
|
||||
table.setItems(model.getList());
|
||||
table.getSelectionModel().selectedItemProperty().addListener(selectedItemChangeListener);
|
||||
PendingTradesListItem selectedItem = model.getSelectedItem();
|
||||
|
|
|
@ -19,6 +19,8 @@ package io.bitsquare.gui.main.portfolio.pendingtrades;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.gui.common.model.ActivatableWithDataModel;
|
||||
import io.bitsquare.gui.common.model.ViewModel;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
|
@ -179,8 +181,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
return dataModel.getTradeProperty();
|
||||
}
|
||||
|
||||
public void fiatPaymentStarted() {
|
||||
dataModel.onFiatPaymentStarted();
|
||||
public void fiatPaymentStarted(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
dataModel.onFiatPaymentStarted(resultHandler, errorMessageHandler);
|
||||
}
|
||||
|
||||
public void fiatPaymentReceived() {
|
||||
|
@ -362,13 +364,10 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
break;
|
||||
|
||||
case DEPOSIT_CONFIRMED:
|
||||
case FIAT_PAYMENT_STARTED:
|
||||
sellerState.set(WAIT_FOR_FIAT_PAYMENT_STARTED);
|
||||
buyerState.set(PendingTradesViewModel.BuyerState.REQUEST_START_FIAT_PAYMENT);
|
||||
break;
|
||||
|
||||
|
||||
case FIAT_PAYMENT_STARTED:
|
||||
break;
|
||||
case FIAT_PAYMENT_STARTED_MSG_SENT:
|
||||
buyerState.set(PendingTradesViewModel.BuyerState.WAIT_FOR_FIAT_PAYMENT_RECEIPT);
|
||||
break;
|
||||
|
|
|
@ -86,7 +86,7 @@ public class StartPaymentView extends TradeStepDetailsView {
|
|||
|
||||
model.getTxId().removeListener(txIdChangeListener);
|
||||
txIdTextField.cleanup();
|
||||
statusProgressIndicator.setProgress(0);
|
||||
removeStatusProgressIndicator();
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,12 +161,40 @@ public class StartPaymentView extends TradeStepDetailsView {
|
|||
|
||||
private void confirmPaymentStarted() {
|
||||
paymentStartedButton.setDisable(true);
|
||||
paymentStartedButton.setMinWidth(130);
|
||||
|
||||
statusProgressIndicator.setVisible(true);
|
||||
statusProgressIndicator.setManaged(true);
|
||||
statusProgressIndicator.setProgress(-1);
|
||||
statusLabel.setText("Sending message to trading partner...");
|
||||
|
||||
model.fiatPaymentStarted();
|
||||
statusLabel.setWrapText(true);
|
||||
statusLabel.setPrefWidth(220);
|
||||
statusLabel.setText("Sending message to your trading partner.\n" +
|
||||
"Please wait until you get the confirmation that the message has arrived.");
|
||||
|
||||
model.fiatPaymentStarted(() -> {
|
||||
// We would not really need an update as the success triggers a screen change
|
||||
removeStatusProgressIndicator();
|
||||
statusLabel.setText("");
|
||||
|
||||
// In case the first send failed we got the support button displayed.
|
||||
// If it succeeds at a second try we remove the support button again.
|
||||
if (openSupportTicketButton != null) {
|
||||
gridPane.getChildren().remove(openSupportTicketButton);
|
||||
openSupportTicketButton = null;
|
||||
}
|
||||
}, errorMessage -> {
|
||||
removeStatusProgressIndicator();
|
||||
statusLabel.setText("Sending message to your trading partner failed.\n" +
|
||||
"Please try again and if it continue to fail report a bug.");
|
||||
paymentStartedButton.setDisable(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void removeStatusProgressIndicator() {
|
||||
statusProgressIndicator.setVisible(false);
|
||||
statusProgressIndicator.setProgress(0);
|
||||
statusProgressIndicator.setManaged(false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bitsquare.gui.components.TitledGroupBg;
|
|||
import io.bitsquare.gui.main.help.Help;
|
||||
import io.bitsquare.gui.main.help.HelpId;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import javafx.geometry.HPos;
|
||||
|
@ -52,7 +53,7 @@ public abstract class TradeStepDetailsView extends AnchorPane {
|
|||
protected Label infoLabel;
|
||||
protected TitledGroupBg infoTitledGroupBg;
|
||||
protected Button openDisputeButton;
|
||||
private Button openSupportTicketButton;
|
||||
protected Button openSupportTicketButton;
|
||||
|
||||
private Trade trade;
|
||||
private Subscription errorMessageSubscription;
|
||||
|
@ -181,7 +182,12 @@ public abstract class TradeStepDetailsView extends AnchorPane {
|
|||
}
|
||||
|
||||
private void addErrorLabel() {
|
||||
if (infoLabel == null) {
|
||||
new Popup().warning(trade.errorMessageProperty().getValue()
|
||||
+ "\n\nPlease report the problem to your arbitrator. He will forward it to the developers to investigate the problem.\n" +
|
||||
"After the problem has be analysed you will get back all the funds you paid in.\n" +
|
||||
"There will be no arbitration fee charged if it was a technical error.").show();
|
||||
|
||||
/*if (infoLabel == null) {
|
||||
infoTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 1, "Error", Layout.GROUP_DISTANCE);
|
||||
infoLabel = addMultilineLabel(gridPane, gridRow, Layout.FIRST_ROW_AND_GROUP_DISTANCE);
|
||||
}
|
||||
|
@ -190,11 +196,10 @@ public abstract class TradeStepDetailsView extends AnchorPane {
|
|||
+ "\n\nPlease report the problem to your arbitrator. He will forward it to the developers to investigate the problem.\n" +
|
||||
"After the problem has be analysed you will get back all the funds you paid in.\n" +
|
||||
"There will be no arbitration fee charged if it was a technical error.");
|
||||
infoLabel.setStyle(" -fx-text-fill: -bs-error-red;");
|
||||
infoLabel.setStyle(" -fx-text-fill: -bs-error-red;");*/
|
||||
|
||||
if (openSupportTicketButton == null) {
|
||||
openSupportTicketButton = addButtonAfterGroup(gridPane, ++gridRow, "Request support");
|
||||
GridPane.setColumnIndex(openSupportTicketButton, 0);
|
||||
openSupportTicketButton = addButton(gridPane, ++gridRow, "Request support");
|
||||
GridPane.setHalignment(openSupportTicketButton, HPos.LEFT);
|
||||
openSupportTicketButton.setOnAction(e -> model.dataModel.onOpenSupportTicket());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue