[bisq-network/bisq] Add UI OfferBook list add/remove checks (#5659)

sqrrm notifications at github.com
Mon Aug 16 17:23:56 CEST 2021


@sqrrm commented on this pull request.



>                  if (!hasSameOffer) {
-                    OfferBookListItem offerBookListItem = new OfferBookListItem(offer);
-                    // We don't use the contains method as the equals method in Offer takes state and errorMessage into account.
-                    // If we have an offer with same ID we remove it and add the new offer as it might have a changed state.
-                    Optional<OfferBookListItem> candidateWithSameId = offerBookListItems.stream()
-                            .filter(item -> item.getOffer().getId().equals(offer.getId()))
-                            .findAny();
-                    if (candidateWithSameId.isPresent()) {
-                        log.warn("We had an old offer in the list with the same Offer ID. We remove the old one. " +
-                                "old offerBookListItem={}, new offerBookListItem={}", candidateWithSameId.get(), offerBookListItem);
-                        offerBookListItems.remove(candidateWithSameId.get());
+                    OfferBookListItem newOfferBookListItem = new OfferBookListItem(offer, hashOfPayload, sequenceNumber);
+                    removeAnyOldOfferBookListItemsBeforeAddingReplacement(newOfferBookListItem);

I find this method name somewhat on the long side

> @@ -79,7 +110,7 @@ public WitnessAgeData getWitnessAgeData(AccountAgeWitnessService accountAgeWitne
                     // either signed & limits lifted, or waiting for limits to be lifted
                     // Or banned
                     daysSinceSignedAsLong = TimeUnit.MILLISECONDS.toDays(optionalWitness.map(witness ->
-                            accountAgeWitnessService.getWitnessSignAge(witness, new Date()))
+                                    accountAgeWitnessService.getWitnessSignAge(witness, new Date()))

Bad indent

> +                    .filter(o -> !isOfferIdBanned(o))
+                    .filter(o -> isV3NodeAddressCompliant(o))

If you use `ifOfferAllowed()` both of these filters can use method references instead. I find that's usually preferred when possible.

>                          offer.getId(),
-                        hashOfPayload.getHex());
+                        hashOfPayload == null ? "null" : hashOfPayload.getHex());
+            }
+
+            // The OfferBookListItem with a null or matching payload-hash was not found.
+            // However, when the API's CLI is used to edit and deactivate an offer
+            // in the same command, the edited offer is not re-published (and cannot be
+            // found in local storage).  In this case, we need to remove the deactivated
+            // offer from the list if the local store does not contain an offer with a
+            // matching offerId.
+            if (!isStoredLocally(offer)) {
+                Optional<OfferBookListItem> viewItem = getOfferBookListItem(offer);
+                viewItem.ifPresent((item) -> {
+                    offerBookListItems.remove(item);

Why is this needed? Isn't this just to present it nicely to the UI and that's not a problem when running the cli?

-- 
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/5659#pullrequestreview-728768353
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210816/c3680365/attachment-0001.htm>


More information about the bisq-github mailing list