mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-24 23:00:36 -04:00
add ui checks for un-authenticated node, fix broadcast issue
This commit is contained in:
parent
88ab1419fa
commit
232c5b46ff
25 changed files with 329 additions and 219 deletions
|
@ -34,6 +34,7 @@ import io.bitsquare.gui.common.view.guice.InjectorViewFactory;
|
|||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.debug.DebugView;
|
||||
import io.bitsquare.gui.popups.EmptyWalletPopup;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.popups.SendAlertMessagePopup;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
|
@ -213,11 +214,7 @@ public class BitsquareApp extends Application {
|
|||
try {
|
||||
throwable.printStackTrace();
|
||||
try {
|
||||
Dialogs.create()
|
||||
.owner(primaryStage)
|
||||
.title("Error")
|
||||
.message("A fatal exception occurred at startup.")
|
||||
.showException(throwable);
|
||||
new Popup().error(throwable.getMessage()).show();
|
||||
} catch (Throwable throwable3) {
|
||||
log.error("Error at displaying Throwable.");
|
||||
throwable3.printStackTrace();
|
||||
|
|
|
@ -219,14 +219,24 @@ public class ArbitratorRegistrationView extends ActivatableViewAndModel<VBox, Ar
|
|||
}
|
||||
|
||||
private void onRevoke() {
|
||||
model.onRevoke(
|
||||
() -> new Popup().information("You have successfully removed your arbitrator from the P2P network.").show(),
|
||||
(errorMessage) -> new Popup().error("Could not remove arbitrator.\nError message: " + errorMessage).show());
|
||||
if (model.isAuthenticated()) {
|
||||
model.onRevoke(
|
||||
() -> new Popup().information("You have successfully removed your arbitrator from the P2P network.").show(),
|
||||
(errorMessage) -> new Popup().error("Could not remove arbitrator.\nError message: " + errorMessage).show());
|
||||
} else {
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
}
|
||||
|
||||
private void onRegister() {
|
||||
model.onRegister(
|
||||
() -> new Popup().information("You have successfully registered your arbitrator to the P2P network.").show(),
|
||||
(errorMessage) -> new Popup().error("Could not register arbitrator.\nError message: " + errorMessage).show());
|
||||
if (model.isAuthenticated()) {
|
||||
model.onRegister(
|
||||
() -> new Popup().information("You have successfully registered your arbitrator to the P2P network.").show(),
|
||||
(errorMessage) -> new Popup().error("Could not register arbitrator.\nError message: " + errorMessage).show());
|
||||
} else {
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,4 +183,8 @@ class ArbitratorRegistrationViewModel extends ActivatableViewModel {
|
|||
registrationEditDisabled.set(!allDataValid || myArbitratorProperty.get() != null);
|
||||
revokeButtonDisabled.set(!allDataValid || myArbitratorProperty.get() == null);
|
||||
}
|
||||
|
||||
boolean isAuthenticated() {
|
||||
return p2PService.isAuthenticated();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import io.bitsquare.gui.popups.WalletPasswordPopup;
|
|||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.TradeCurrency;
|
||||
import io.bitsquare.p2p.Address;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.payment.SepaAccount;
|
||||
|
@ -51,6 +50,8 @@ import org.jetbrains.annotations.NotNull;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Domain for that UI element.
|
||||
* Note that the create offer domain has a deeper scope in the application domain (TradeManager).
|
||||
|
@ -62,8 +63,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
private final TradeWalletService tradeWalletService;
|
||||
private final Preferences preferences;
|
||||
private final User user;
|
||||
private final Address address;
|
||||
private final KeyRing keyRing;
|
||||
private P2PService p2PService;
|
||||
private final WalletPasswordPopup walletPasswordPopup;
|
||||
private final BSFormatter formatter;
|
||||
private final String offerId;
|
||||
|
@ -110,10 +111,10 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
this.preferences = preferences;
|
||||
this.user = user;
|
||||
this.keyRing = keyRing;
|
||||
this.p2PService = p2PService;
|
||||
this.walletPasswordPopup = walletPasswordPopup;
|
||||
this.formatter = formatter;
|
||||
|
||||
address = p2PService.getAddress();
|
||||
offerId = UUID.randomUUID().toString();
|
||||
addressEntry = walletService.getAddressEntryByOfferId(offerId);
|
||||
offerFeeAsCoin = FeePolicy.CREATE_OFFER_FEE;
|
||||
|
@ -199,8 +200,9 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
// That is optional and set to null if not supported (AltCoins, OKPay,...)
|
||||
Country country = paymentAccount.getCountry();
|
||||
|
||||
checkNotNull(p2PService.getAddress(), "Address must not be null");
|
||||
return new Offer(offerId,
|
||||
address,
|
||||
p2PService.getAddress(),
|
||||
keyRing.getPubKeyRing(),
|
||||
direction,
|
||||
fiatPrice,
|
||||
|
|
|
@ -201,17 +201,22 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
|||
|
||||
private void onPlaceOffer() {
|
||||
Offer offer = model.getOffer();
|
||||
if (model.getShowPlaceOfferConfirmation()) {
|
||||
offerDetailsPopup.onPlaceOffer(o -> model.onPlaceOffer(o)).show(offer);
|
||||
} else {
|
||||
if (model.hasAcceptedArbitrators()) {
|
||||
model.onPlaceOffer(offer);
|
||||
if (model.isAuthenticated()) {
|
||||
if (model.getShowPlaceOfferConfirmation()) {
|
||||
offerDetailsPopup.onPlaceOffer(o -> model.onPlaceOffer(o)).show(offer);
|
||||
} else {
|
||||
new Popup().warning("You have no arbitrator selected.\n" +
|
||||
"Please select at least one arbitrator.").show();
|
||||
if (model.hasAcceptedArbitrators()) {
|
||||
model.onPlaceOffer(offer);
|
||||
} else {
|
||||
new Popup().warning("You have no arbitrator selected.\n" +
|
||||
"Please select at least one arbitrator.").show();
|
||||
|
||||
navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, ArbitratorSelectionView.class);
|
||||
navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, ArbitratorSelectionView.class);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import io.bitsquare.gui.util.validation.FiatValidator;
|
|||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.TradeCurrency;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
import javafx.beans.property.*;
|
||||
|
@ -42,6 +43,7 @@ import static javafx.beans.binding.Bindings.createStringBinding;
|
|||
|
||||
class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel> implements ViewModel {
|
||||
private final BtcValidator btcValidator;
|
||||
private P2PService p2PService;
|
||||
private final BSFormatter formatter;
|
||||
private final FiatValidator fiatValidator;
|
||||
|
||||
|
@ -100,11 +102,13 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
|
||||
@Inject
|
||||
public CreateOfferViewModel(CreateOfferDataModel dataModel, FiatValidator fiatValidator, BtcValidator btcValidator,
|
||||
P2PService p2PService,
|
||||
BSFormatter formatter) {
|
||||
super(dataModel);
|
||||
|
||||
this.fiatValidator = fiatValidator;
|
||||
this.btcValidator = btcValidator;
|
||||
this.p2PService = p2PService;
|
||||
this.formatter = formatter;
|
||||
|
||||
paymentLabel = BSResources.get("createOffer.fundsBox.paymentLabel", dataModel.getOfferId());
|
||||
|
@ -335,8 +339,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
if (!dataModel.isMinAmountLessOrEqualAmount()) {
|
||||
amountValidationResult.set(new InputValidator.ValidationResult(false,
|
||||
BSResources.get("createOffer.validation.amountSmallerThanMinAmount")));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
amountValidationResult.set(result);
|
||||
if (minAmount.get() != null)
|
||||
minAmountValidationResult.set(isBtcInputValid(minAmount.get()));
|
||||
|
@ -357,8 +360,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
if (!dataModel.isMinAmountLessOrEqualAmount()) {
|
||||
minAmountValidationResult.set(new InputValidator.ValidationResult(false,
|
||||
BSResources.get("createOffer.validation.minAmountLargerThanAmount")));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
minAmountValidationResult.set(result);
|
||||
if (amount.get() != null)
|
||||
amountValidationResult.set(isBtcInputValid(amount.get()));
|
||||
|
@ -467,6 +469,10 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
return dataModel.hasAcceptedArbitrators();
|
||||
}
|
||||
|
||||
boolean isAuthenticated() {
|
||||
return p2PService.isAuthenticated();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Utils
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -486,8 +492,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
if (!dataModel.isMinAmountLessOrEqualAmount()) {
|
||||
amountValidationResult.set(new InputValidator.ValidationResult(false,
|
||||
BSResources.get("createOffer.validation.amountSmallerThanMinAmount")));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (amount.get() != null)
|
||||
amountValidationResult.set(isBtcInputValid(amount.get()));
|
||||
if (minAmount.get() != null)
|
||||
|
@ -524,7 +529,8 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
}
|
||||
|
||||
private void updateButtonDisableState() {
|
||||
isPlaceOfferButtonDisabled.set(!(isBtcInputValid(amount.get()).isValid &&
|
||||
isPlaceOfferButtonDisabled.set(
|
||||
!(isBtcInputValid(amount.get()).isValid &&
|
||||
isBtcInputValid(minAmount.get()).isValid &&
|
||||
isFiatInputValid(price.get()).isValid &&
|
||||
isFiatInputValid(volume.get()).isValid &&
|
||||
|
@ -544,4 +550,5 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
public boolean getShowPlaceOfferConfirmation() {
|
||||
return dataModel.getShowPlaceOfferConfirmation();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.offer.offerbook;
|
||||
|
||||
import io.bitsquare.p2p.storage.HashSetChangedListener;
|
||||
import io.bitsquare.p2p.storage.HashMapChangedListener;
|
||||
import io.bitsquare.p2p.storage.data.ProtectedData;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
|
@ -53,7 +53,7 @@ public class OfferBook {
|
|||
@Inject
|
||||
OfferBook(OfferBookService offerBookService, TradeManager tradeManager) {
|
||||
this.offerBookService = offerBookService;
|
||||
offerBookService.addHashSetChangedListener(new HashSetChangedListener() {
|
||||
offerBookService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
@Override
|
||||
public void onAdded(ProtectedData entry) {
|
||||
log.debug("onAdded " + entry);
|
||||
|
|
|
@ -26,6 +26,21 @@ public class OfferBookListItem {
|
|||
this.offer = offer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof OfferBookListItem)) return false;
|
||||
|
||||
OfferBookListItem that = (OfferBookListItem) o;
|
||||
|
||||
return !(offer != null ? !offer.equals(that.offer) : that.offer != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return offer != null ? offer.hashCode() : 0;
|
||||
}
|
||||
|
||||
public Offer getOffer() {
|
||||
return offer;
|
||||
}
|
||||
|
|
|
@ -211,8 +211,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
showWarning("You don't have an arbitrator selected.",
|
||||
"You need to setup at least one arbitrator to be able to trade.\n" +
|
||||
"Do you want to do this now?", ArbitratorSelectionView.class);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
createOfferButton.setDisable(true);
|
||||
offerActionHandler.onCreateOffer(model.getTradeCurrency());
|
||||
}
|
||||
|
@ -231,21 +230,30 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
}
|
||||
|
||||
private void onTakeOffer(Offer offer) {
|
||||
offerActionHandler.onTakeOffer(offer);
|
||||
if (model.isAuthenticated())
|
||||
offerActionHandler.onTakeOffer(offer);
|
||||
else
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
|
||||
private void onRemoveOpenOffer(Offer offer) {
|
||||
model.onRemoveOpenOffer(offer,
|
||||
() -> {
|
||||
log.debug("Remove offer was successful");
|
||||
new Popup().information("You can withdraw the funds you paid in from the funds screens.").show();
|
||||
navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
|
||||
},
|
||||
(message) -> {
|
||||
log.error(message);
|
||||
new Popup().warning("Remove offer failed:\n" + message).show();
|
||||
});
|
||||
if (model.isAuthenticated()) {
|
||||
model.onRemoveOpenOffer(offer,
|
||||
() -> {
|
||||
log.debug("Remove offer was successful");
|
||||
new Popup().information("You can withdraw the funds you paid in from the funds screens.").show();
|
||||
navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
|
||||
},
|
||||
(message) -> {
|
||||
log.error(message);
|
||||
new Popup().warning("Remove offer failed:\n" + message).show();
|
||||
});
|
||||
|
||||
} else {
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
}
|
||||
|
||||
private void showWarning(String masthead, String message, Class target) {
|
||||
|
@ -446,8 +454,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
title = model.getDirectionLabel(offer);
|
||||
button.setOnAction(e -> onTakeOffer(offer));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
title = "Not matching";
|
||||
iconView.setId(null);
|
||||
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator));
|
||||
|
@ -455,8 +462,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
|
||||
button.setText(title);
|
||||
setGraphic(button);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setGraphic(null);
|
||||
TableRow tableRow = getTableRow();
|
||||
if (tableRow != null) tableRow.setOpacity(1);
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.bitsquare.locale.CountryUtil;
|
|||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.locale.TradeCurrency;
|
||||
import io.bitsquare.p2p.Address;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
import io.bitsquare.payment.SepaAccount;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
|
@ -49,6 +50,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
private final User user;
|
||||
private final OfferBook offerBook;
|
||||
private final Preferences preferences;
|
||||
private final P2PService p2PService;
|
||||
private final BSFormatter formatter;
|
||||
|
||||
private final FilteredList<OfferBookListItem> filteredItems;
|
||||
|
@ -69,7 +71,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
|
||||
@Inject
|
||||
public OfferBookViewModel(User user, OpenOfferManager openOfferManager, OfferBook offerBook,
|
||||
Preferences preferences,
|
||||
Preferences preferences, P2PService p2PService,
|
||||
BSFormatter formatter) {
|
||||
super();
|
||||
|
||||
|
@ -77,6 +79,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
this.user = user;
|
||||
this.offerBook = offerBook;
|
||||
this.preferences = preferences;
|
||||
this.p2PService = p2PService;
|
||||
this.formatter = formatter;
|
||||
|
||||
offerBookListItems = offerBook.getOfferBookListItems();
|
||||
|
@ -155,6 +158,10 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
return list;
|
||||
}
|
||||
|
||||
boolean isAuthenticated() {
|
||||
return p2PService.isAuthenticated();
|
||||
}
|
||||
|
||||
public TradeCurrency getTradeCurrency() {
|
||||
return tradeCurrency;
|
||||
}
|
||||
|
|
|
@ -75,4 +75,6 @@ class OpenOffersDataModel extends ActivatableDataModel {
|
|||
// we sort by date, earliest first
|
||||
list.sort((o1, o2) -> o2.getOffer().getDate().compareTo(o1.getOffer().getDate()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,8 +38,10 @@ import javax.inject.Inject;
|
|||
@FxmlView
|
||||
public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersViewModel> {
|
||||
|
||||
@FXML TableView<OpenOfferListItem> table;
|
||||
@FXML TableColumn<OpenOfferListItem, OpenOfferListItem> priceColumn, amountColumn, volumeColumn,
|
||||
@FXML
|
||||
TableView<OpenOfferListItem> table;
|
||||
@FXML
|
||||
TableColumn<OpenOfferListItem, OpenOfferListItem> priceColumn, amountColumn, volumeColumn,
|
||||
directionColumn, dateColumn, offerIdColumn, removeItemColumn;
|
||||
private final Navigation navigation;
|
||||
private final OfferDetailsPopup offerDetailsPopup;
|
||||
|
@ -71,18 +73,22 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
|
|||
}
|
||||
|
||||
private void onCancelOpenOffer(OpenOffer openOffer) {
|
||||
model.onCancelOpenOffer(openOffer,
|
||||
() -> {
|
||||
log.debug("Remove offer was successful");
|
||||
new Popup().information("You can withdraw the funds you paid in from the funds screens.")
|
||||
.onClose(() -> navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class))
|
||||
.show();
|
||||
},
|
||||
(message) -> {
|
||||
log.error(message);
|
||||
new Popup().warning("Remove offer failed:\n" + message).show();
|
||||
});
|
||||
|
||||
if (model.isAuthenticated()) {
|
||||
model.onCancelOpenOffer(openOffer,
|
||||
() -> {
|
||||
log.debug("Remove offer was successful");
|
||||
new Popup().information("You can withdraw the funds you paid in from the funds screens.")
|
||||
.onClose(() -> navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class))
|
||||
.show();
|
||||
},
|
||||
(message) -> {
|
||||
log.error(message);
|
||||
new Popup().warning("Remove offer failed:\n" + message).show();
|
||||
});
|
||||
} else {
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
}
|
||||
|
||||
/* private void openOfferDetails(OpenOfferListItem item) {
|
||||
|
@ -144,8 +150,7 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
|
|||
Tooltip.install(hyperlink, new Tooltip(model.getTradeId(item)));
|
||||
hyperlink.setOnAction(event -> offerDetailsPopup.show(item.getOffer()));
|
||||
setGraphic(hyperlink);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setGraphic(null);
|
||||
setId(null);
|
||||
}
|
||||
|
@ -281,8 +286,7 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
|
|||
if (item != null) {
|
||||
button.setOnAction(event -> onCancelOpenOffer(item.getOpenOffer()));
|
||||
setGraphic(button);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,16 +23,19 @@ 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;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.trade.offer.OpenOffer;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
class OpenOffersViewModel extends ActivatableWithDataModel<OpenOffersDataModel> implements ViewModel {
|
||||
private P2PService p2PService;
|
||||
private final BSFormatter formatter;
|
||||
|
||||
|
||||
@Inject
|
||||
public OpenOffersViewModel(OpenOffersDataModel dataModel, BSFormatter formatter) {
|
||||
public OpenOffersViewModel(OpenOffersDataModel dataModel, P2PService p2PService, BSFormatter formatter) {
|
||||
super(dataModel);
|
||||
this.p2PService = p2PService;
|
||||
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
@ -70,4 +73,7 @@ class OpenOffersViewModel extends ActivatableWithDataModel<OpenOffersDataModel>
|
|||
return formatter.formatDateTime(item.getOffer().getDate());
|
||||
}
|
||||
|
||||
boolean isAuthenticated() {
|
||||
return p2PService.isAuthenticated();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.bitsquare.gui.common.model.ViewModel;
|
|||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.*;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import javafx.beans.property.*;
|
||||
|
@ -72,6 +73,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
private final InputValidator inputValidator;
|
||||
private final OKPayValidator okPayValidator;
|
||||
private final AltCoinAddressValidator altCoinAddressValidator;
|
||||
private P2PService p2PService;
|
||||
|
||||
private final ObjectProperty<BuyerState> buyerState = new SimpleObjectProperty<>(PendingTradesViewModel.BuyerState.UNDEFINED);
|
||||
private final ObjectProperty<SellerState> sellerState = new SimpleObjectProperty<>(UNDEFINED);
|
||||
|
@ -92,7 +94,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
BICValidator bicValidator,
|
||||
InputValidator inputValidator,
|
||||
OKPayValidator okPayValidator,
|
||||
AltCoinAddressValidator altCoinAddressValidator
|
||||
AltCoinAddressValidator altCoinAddressValidator,
|
||||
P2PService p2PService
|
||||
) {
|
||||
super(dataModel);
|
||||
|
||||
|
@ -103,6 +106,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
this.inputValidator = inputValidator;
|
||||
this.okPayValidator = okPayValidator;
|
||||
this.altCoinAddressValidator = altCoinAddressValidator;
|
||||
this.p2PService = p2PService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,6 +219,10 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
return btcAddressValidator;
|
||||
}
|
||||
|
||||
public boolean isAuthenticated() {
|
||||
return p2PService.isAuthenticated();
|
||||
}
|
||||
|
||||
// columns
|
||||
String formatTradeId(String value) {
|
||||
return value;
|
||||
|
|
|
@ -19,6 +19,7 @@ package io.bitsquare.gui.main.portfolio.pendingtrades.steps;
|
|||
|
||||
import io.bitsquare.gui.components.TxIdTextField;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.event.ActionEvent;
|
||||
|
@ -103,13 +104,18 @@ public class ConfirmPaymentReceivedView extends TradeStepDetailsView {
|
|||
|
||||
private void onPaymentReceived(ActionEvent actionEvent) {
|
||||
log.debug("onPaymentReceived");
|
||||
confirmFiatReceivedButton.setDisable(true);
|
||||
if (model.isAuthenticated()) {
|
||||
confirmFiatReceivedButton.setDisable(true);
|
||||
|
||||
statusProgressIndicator.setVisible(true);
|
||||
statusProgressIndicator.setProgress(-1);
|
||||
statusLabel.setText("Sending message to trading partner...");
|
||||
statusProgressIndicator.setVisible(true);
|
||||
statusProgressIndicator.setProgress(-1);
|
||||
statusLabel.setText("Sending message to trading partner...");
|
||||
|
||||
model.fiatPaymentReceived();
|
||||
model.fiatPaymentReceived();
|
||||
} else {
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bitsquare.gui.components.TitledGroupBg;
|
|||
import io.bitsquare.gui.components.TxIdTextField;
|
||||
import io.bitsquare.gui.components.paymentmethods.*;
|
||||
import io.bitsquare.gui.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||
import io.bitsquare.gui.popups.Popup;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
|
@ -124,13 +125,18 @@ public class StartPaymentView extends TradeStepDetailsView {
|
|||
|
||||
private void onPaymentStarted(ActionEvent actionEvent) {
|
||||
log.debug("onPaymentStarted");
|
||||
paymentStartedButton.setDisable(true);
|
||||
if (model.isAuthenticated()) {
|
||||
paymentStartedButton.setDisable(true);
|
||||
|
||||
statusProgressIndicator.setVisible(true);
|
||||
statusProgressIndicator.setProgress(-1);
|
||||
statusLabel.setText("Sending message to trading partner...");
|
||||
statusProgressIndicator.setVisible(true);
|
||||
statusProgressIndicator.setProgress(-1);
|
||||
statusLabel.setText("Sending message to trading partner...");
|
||||
|
||||
model.fiatPaymentStarted();
|
||||
model.fiatPaymentStarted();
|
||||
} else {
|
||||
new Popup().warning("You need to wait until your client is authenticated in the network.\n" +
|
||||
"That might take up to about 2 minutes at startup.").show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue