Skip to content

Commit

Permalink
Hide time since signing column when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ripcurlx committed Oct 8, 2019
1 parent 37d38a5 commit 5f80e1f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ public static boolean hasChargebackRisk(PaymentMethod paymentMethod, List<TradeC
.anyMatch(tradeCurrency -> hasChargebackRisk(paymentMethod, tradeCurrency.getCode()));
}

public static boolean hasChargebackRisk(PaymentMethod paymentMethod) {
return hasChargebackRisk(paymentMethod, CurrencyUtil.getMatureMarketCurrencies());
}

public static boolean hasChargebackRisk(PaymentMethod paymentMethod, String currencyCode) {
if (paymentMethod == null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
private AutocompleteComboBox<TradeCurrency> currencyComboBox;
private AutocompleteComboBox<PaymentMethod> paymentMethodComboBox;
private AutoTooltipButton createOfferButton;
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> amountColumn, volumeColumn, marketColumn, priceColumn, signingStateColumn, avatarColumn;
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> amountColumn, volumeColumn, marketColumn,
priceColumn, paymentMethodColumn, signingStateColumn, avatarColumn;
private TableView<OfferBookListItem> tableView;

private OfferView.OfferActionHandler offerActionHandler;
Expand Down Expand Up @@ -220,7 +221,7 @@ public void initialize() {
tableView.getColumns().add(amountColumn);
volumeColumn = getVolumeColumn();
tableView.getColumns().add(volumeColumn);
TableColumn<OfferBookListItem, OfferBookListItem> paymentMethodColumn = getPaymentMethodColumn();
paymentMethodColumn = getPaymentMethodColumn();
tableView.getColumns().add(paymentMethodColumn);
signingStateColumn = getSigningStateColumn();
tableView.getColumns().add(signingStateColumn);
Expand Down Expand Up @@ -310,6 +311,7 @@ protected void activate() {
if (paymentMethodComboBox.getEditor().getText().isEmpty())
paymentMethodComboBox.getSelectionModel().select(SHOW_ALL);
model.onSetPaymentMethod(paymentMethodComboBox.getSelectionModel().getSelectedItem());
updateSigningStateColumn();
});

if (model.showAllPaymentMethods)
Expand Down Expand Up @@ -339,6 +341,8 @@ protected void activate() {
tableView.getColumns().remove(marketColumn);
}

updateSigningStateColumn();

return null;
});

Expand All @@ -353,6 +357,16 @@ protected void activate() {
model.priceFeedService.updateCounterProperty().addListener(priceFeedUpdateCounterListener);
}

private void updateSigningStateColumn() {
if (model.hasSelectionAccountSigning()) {
if (!tableView.getColumns().contains(signingStateColumn)) {
tableView.getColumns().add(tableView.getColumns().indexOf(paymentMethodColumn) + 1, signingStateColumn);
}
} else {
tableView.getColumns().remove(signingStateColumn);
}
}

@Override
protected void deactivate() {
createOfferButton.setOnAction(null);
Expand Down Expand Up @@ -865,8 +879,8 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
return column;
}

private TableColumn<OfferBookListItem, OfferBookListItem> getPaymentMethodColumn() {
TableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.paymentMethod")) {
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getPaymentMethodColumn() {
AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.paymentMethod")) {
{
setMinWidth(80);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ void onSetPaymentMethod(PaymentMethod paymentMethod) {
showAllPaymentMethods = isShowAllEntry(paymentMethod.getId());
if (!showAllPaymentMethods)
this.selectedPaymentMethod = paymentMethod;
else
this.selectedPaymentMethod = PaymentMethod.getDummyPaymentMethod(GUIUtil.SHOW_ALL_FLAG);

applyFilterPredicate();
}
Expand Down Expand Up @@ -567,7 +569,7 @@ boolean requireUpdateToNewVersion() {
boolean isInsufficientCounterpartyTradeLimit(Offer offer) {
return CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) &&
!accountAgeWitnessService.verifyPeersTradeAmount(offer, offer.getAmount(), errorMessage -> {
});
});
}

boolean isMyInsufficientTradeLimit(Offer offer) {
Expand Down Expand Up @@ -608,4 +610,19 @@ int getNumTrades(Offer offer) {
.collect(Collectors.toSet())
.size();
}

public boolean hasSelectionAccountSigning() {
if (showAllTradeCurrenciesProperty.get()) {
if (!selectedPaymentMethod.getId().equals(GUIUtil.SHOW_ALL_FLAG)) {
return PaymentMethod.hasChargebackRisk(selectedPaymentMethod);
}
} else {
if (selectedPaymentMethod.getId().equals(GUIUtil.SHOW_ALL_FLAG))
return CurrencyUtil.getMatureMarketCurrencies().stream()
.anyMatch(c -> c.getCode().equals(selectedTradeCurrency.getCode()));
else
return PaymentMethod.hasChargebackRisk(selectedPaymentMethod, tradeCurrencyCode.get());
}
return true;
}
}

0 comments on commit 5f80e1f

Please sign in to comment.