<p></p>
<p><b>@sqrrm</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/5666#discussion_r695653474">desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java</a>:</p>
<pre style='color:#555'>>              }
         });
     }
 
-    public void removeOffer(Offer offer, TradeManager tradeManager) {
+    private void removeDuplicateItem(OfferBookListItem newOfferBookListItem) {
+        String offerId = newOfferBookListItem.getOffer().getId();
+        // We need to remove any view items with a matching offerId before
+        // a newOfferBookListItem is added to the view.
+        List<OfferBookListItem> duplicateItems = offerBookListItems.stream()
+                .filter(item -> item.getOffer().getId().equals(offerId))
+                .collect(Collectors.toList());
+        if (duplicateItems.size() > 0) {
</pre>
<p>This check is not needed since <code>forEach</code> won't do anything if there are no items in the list.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/5666#discussion_r695654221">desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java</a>:</p>
<pre style='color:#555'>> +                if (log.isDebugEnabled()) {
+                    log.debug("onAdded: Removed old offer {}\n"
+                                    + "\twith payload hash {} from list.\n"
+                                    + "\tThis may make a subsequent onRemoved( {} ) call redundant.",
+                            offerId,
+                            oldOfferItem.getHashOfPayload() == null ? "null" : oldOfferItem.getHashOfPayload().getHex(),
+                            oldOfferItem.getOffer().getId());
+                }
</pre>
<p>There are still a lot of debug logs. Do you want to keep them for the first release with these changes? If so, I think it would be good to add a TODO to remove them later as I don't think they're that valuable in the long run.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/5666#discussion_r695659901">desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java</a>:</p>
<pre style='color:#555'>> +        if (!candidateWithMatchingPayloadHash.isPresent()) {
+            if (log.isDebugEnabled()) {
+                log.debug("UI view list does not contain offer with id {} and payload-hash {}",
+                        offer.getId(),
+                        hashOfPayload == null ? "null" : hashOfPayload.getHex());
+            }
+            return;
+        }
+
+        OfferBookListItem candidate = candidateWithMatchingPayloadHash.get();
+
+        // Remove the candidate only if the candidate's offer payload hash matches the
+        // onRemoved hashOfPayload parameter.  We may receive add/remove messages out of
+        // order (from api's 'editoffer'), and use the offer payload hash to
+        // ensure we do not remove an edited offer immediately after it was added.
+        if ((candidate.getHashOfPayload() == null || candidate.getHashOfPayload().equals(hashOfPayload))) {
</pre>
<p>Does this mean an item with null hash will be removed if only the id matches? Seems like a way to get around the hash checks.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/5666#pullrequestreview-738221680">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNQGML6DOLMXDNHU72DT6THSZANCNFSM5CIFYDRA">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email">Android</a>.<img src="https://github.com/notifications/beacon/AJFFTNRF2HU2LG24QUFUDW3T6THSZA5CNFSM5CIFYDRKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOFQAF44A.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/5666#pullrequestreview-738221680",
"url": "https://github.com/bisq-network/bisq/pull/5666#pullrequestreview-738221680",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>