Sparrow dom/historical listing fix#3250
Conversation
|
Thanks @sparrowDom 👏 Can we get more whitespace below that yellow alert? Probably about the same as below the blue button. Also, I'm wondering since you used the word "available", do we necessarily know here that the listing has availability? Or could a buyer click the blue button and then see "sold out" on the next screen. Or will that entire section change state on this initial screen and not display the alert/button at all? |
|
@sparrowDom let's also hide the "Your ETH will..." in this case. And for that matter, I would probably recommend hiding |
…ing is available. Also refactor code
|
As requested warning now looks like this @micahalcorn : Do tell if any additional tweaks are required. @nick PTAL when you can spare some time |
shahthepro
left a comment
There was a problem hiding this comment.
Great work @sparrowDom. Few comments inline. Looks good to me. But @nick may want to take a pass too.
| } else if (isHistoricalListing(this.props.listing)) { | ||
| action = ( | ||
| <HistoricalListingWarning | ||
| listingId={currentListingIdFromHistoricalId(this.props.listing)} |
There was a problem hiding this comment.
nit: If the component is named HistoricalListingWarning, I'd expect the parameter listingId to be the id of the historical listing and not of the latest listing. Perhaps, could move currentListingIdFromHistoricalId function call inside the HistoricalListingWarning or rename listingId to latestListingId. Just my opinion though.
There was a problem hiding this comment.
Yeah agreed. Moving the original listing resolution to historicalListingWarning component
| @@ -0,0 +1,19 @@ | |||
| const regex = /(\d*)-(\d*)-(\d*)-(\d*)/ | |||
There was a problem hiding this comment.
You may want to switch it to /(\d+)-(\d+)-(\d+)-(\d+)/. But shouldn't be problem with * too since we won't have listing Ids with trailing or leading '-'.
There was a problem hiding this comment.
Also, you may want to specify ^ and $ characters to be more defensive.
There was a problem hiding this comment.
All good points thanks
| * This can happen when for example user clicks on a listing from a Purchase detail view | ||
| */ | ||
| export function isHistoricalListing(listing) { | ||
| return !!listing.id.match(regex) |
There was a problem hiding this comment.
Instead of !! and .match, regex.test(listing.id) can be used. .test() will always return a boolean.
| noEthOrDai = false | ||
|
|
||
| if (hasIdentity) { | ||
| if (hasIdentity && !isHistoricalListing(listing)) { |
There was a problem hiding this comment.
Why not move this check out of this component? We could avoid rendering PaymentOptions if it is a historical component right?
There was a problem hiding this comment.
PaymentOptions has children that it needs to render. If we disable the rendering of payment options then components like _BuySingleUnit and Buy do not get rendered either:
origin/dapps/marketplace/src/pages/listing/_BuySingleUnit.js
Lines 62 to 75 in 5aa1d52
There was a problem hiding this comment.
Yeah, But we don't want users to make offer on historical listing, if I'm not mistaken.
From what I understand, we would have a "View Current Listing" instead of "Purchase" button right?
There was a problem hiding this comment.
The button that displays the "View Current Listing" is a Buy button component. This ensures us that a user is never able to make an offer on a historical listing since the buy button will always say "View current listing" instead of "Purchase".
And that buy button is part of the children that get passed to the PaymentOption Component.
micahalcorn
left a comment
There was a problem hiding this comment.
I haven't tested this myself, but I'm under the impression that we still need to make some changes here.
The basic issue (I'm told) is that, if a buyer visits a listing detail with a block number in the URL's listing id param, then after making an offer from that block-specific listing, the user will be routed to a transaction detail page with its URL offer id param being polluted with an unnecessary block number, which gets interpreted incorrectly and throws the exception described in #3237. This issue applies whether or not the listing has been updated.
So here is what I was proposing for when the listing detail page is block-number-specific:
- If the listing has been updated and I am not looking at the newest version, then display the new UI as this PR does.
- If the listing has not been updated or I am looking at the newest version, then the transaction detail navigation should be smart enough not to route me using an invalid offer id (polluted by a block number).
|
thanks @shahthepro for a great review. Merging in once tests pass |
…otocol/origin into sparrowDom/historicalListingFix
|
@micahalcorn just saw your comment if you are ok with it going with the following solution: If a user is looking at the newest version of the listing in listingDetail the component just redirects to newest version (without the block number in the url) before rendering the "historical view" of the listing version. /cc @shahthepro the commit doing this: b4cc886 |
|
Merging this in... @micahalcorn & @shahthepro if any additional changes requested will be resolved in subsequent PRs |
|
I don’t quite understand, @sparrowDom. 😕 The block numbered version only renders if it is NOT the current version? And if it is, it redirects to a URL with no block number? |
|
Yes @micahalcorn it works exactly like you describe:
Do you think we should take a different approach, or that this one could be confusing? |
|
@sparrowDom thanks, that certainly works from the user's perspective, and it sounds like the simplest from the engineering perspective. I would think that it might not be ideologically appropriate, but I don't have strong opinions. 🤷♂ |
|
Yeah it was the simplest solution. Happy to change it to something else if need/wish be. |

Description:
Your Eth will be transferred to escrowinfo box.Related Issue: #3237

Checklist:
fbtfor translationnpm run translate