[bisq-network/bisq] Refactor PendingTradesViewModel methods -> TradeUtil & OfferUtil (#4699)

sqrrm notifications at github.com
Thu Oct 29 23:07:08 UTC 2020


@sqrrm commented on this pull request.



>      }
 
     public String getRemainingTradeDurationAsWords() {
-        return FormattingUtils.formatDurationAsWords(Math.max(0, getRemainingTradeDuration()));
+        return tradeUtil.getRemainingTradeDurationAsWords(dataModel.getTrade());

I think a check for non null Trade would be good here.

>      }
 
     public String getDateForOpenDispute() {
-        return DisplayUtils.formatDateTime(new Date(new Date().getTime() + getRemainingTradeDuration()));
+        return DisplayUtils.formatDateTime(tradeUtil.getDateForOpenDispute(dataModel.getTrade()));

Also no check for null Trade

> +    public Date getDateForOpenDispute(Trade trade) {
+        return new Date(new Date().getTime() + getRemainingTradeDuration(trade));
+    }
+
+    public String getMarketDescription(Trade trade) {
+        if (trade == null)
+            return "";
+
+        checkNotNull(trade.getOffer());
+        checkNotNull(trade.getOffer().getCurrencyCode());
+        return getCurrencyPair(trade.getOffer().getCurrencyCode());
+    }
+
+    public String getPaymentMethodNameWithCountryCode(Trade trade) {
+        String paymentMethodDescription = "";
+        if (trade != null) {

Prefer to return early, ie
```
if (trade == null)
    return;

Offer offer = checkNotNull(trade.getOffer());
checkNotNull(offer.getPaymentMethod());
return offer.getPaymentMethodNameWithCountryCode();
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4699#pullrequestreview-520141161
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201029/68b6a9d8/attachment.html>


More information about the bisq-github mailing list