Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Sparrow dom/historical listing fix#3250

Merged
sparrowDom merged 13 commits into
masterfrom
sparrowDom/historicalListingFix
Sep 8, 2019
Merged

Sparrow dom/historical listing fix#3250
sparrowDom merged 13 commits into
masterfrom
sparrowDom/historicalListingFix

Conversation

@sparrowDom

@sparrowDom sparrowDom commented Sep 6, 2019

Copy link
Copy Markdown
Member

Description:

  • When user is observing a historical listing replace the purchase option with a "View current listing" button.
  • Also hide total payment amount and Your Eth will be transferred to escrow info box.

Related Issue: #3237
Screenshot 2019-09-06 19 47 31

Checklist:

@sparrowDom sparrowDom self-assigned this Sep 6, 2019
@sparrowDom
sparrowDom requested a review from nick September 6, 2019 17:53
@nick
nick requested a review from micahalcorn September 6, 2019 19:53
@sparrowDom sparrowDom mentioned this pull request Sep 6, 2019
@micahalcorn

Copy link
Copy Markdown
Member

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?

@micahalcorn

micahalcorn commented Sep 6, 2019

Copy link
Copy Markdown
Member

@sparrowDom let's also hide the "Your ETH will..." in this case. And for that matter, I would probably recommend hiding all of the quantity+total+ payment as we do when the buyer has not yet onboarded. 🤔

@sparrowDom

Copy link
Copy Markdown
Member Author

As requested warning now looks like this @micahalcorn :
Screenshot 2019-09-06 23 38 18

Do tell if any additional tweaks are required.

@nick PTAL when you can spare some time

@shahthepro shahthepro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed. Moving the original listing resolution to historicalListingWarning component

Comment thread dapps/marketplace/src/utils/listing.js Outdated
@@ -0,0 +1,19 @@
const regex = /(\d*)-(\d*)-(\d*)-(\d*)/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 '-'.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you may want to specify ^ and $ characters to be more defensive.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good points thanks

Comment thread dapps/marketplace/src/utils/listing.js Outdated
* 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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of !! and .match, regex.test(listing.id) can be used. .test() will always return a boolean.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, changed to that

noEthOrDai = false

if (hasIdentity) {
if (hasIdentity && !isHistoricalListing(listing)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move this check out of this component? We could avoid rendering PaymentOptions if it is a historical component right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

<PaymentOptions
tokens={prices}
price={listing.price}
acceptedTokens={listing.acceptedTokens}
value={token}
hasBalance={tokenStatus.hasBalance}
hasEthBalance={tokenStatus.hasEthBalance}
>
<ConfirmShippingAndPurchase
listing={listing}
className="btn btn-primary"
children={fbt('Purchase', 'Purchase')}
/>
</PaymentOptions>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 micahalcorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. If the listing has been updated and I am not looking at the newest version, then display the new UI as this PR does.
  2. 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).

@sparrowDom

Copy link
Copy Markdown
Member Author

thanks @shahthepro for a great review. Merging in once tests pass

@sparrowDom

sparrowDom commented Sep 8, 2019

Copy link
Copy Markdown
Member Author

@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

@sparrowDom

Copy link
Copy Markdown
Member Author

Merging this in...

@micahalcorn & @shahthepro if any additional changes requested will be resolved in subsequent PRs

@sparrowDom
sparrowDom merged commit f5ed22b into master Sep 8, 2019
@sparrowDom
sparrowDom deleted the sparrowDom/historicalListingFix branch September 8, 2019 11:51
@micahalcorn

Copy link
Copy Markdown
Member

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?

@sparrowDom

Copy link
Copy Markdown
Member Author

Yes @micahalcorn it works exactly like you describe:

  • listing with a block number in the url that is also the current listing version will immediately redirect to the current listing view that has no block number in the url. Rendering the purchase button (the whole redirect happens fast is not something I noticed)
  • listing with a block number in the url that is not the current listing version will render the historical listing having a "View current listing" button instead of a purchase button and a yellow warning.

Do you think we should take a different approach, or that this one could be confusing?

@micahalcorn

Copy link
Copy Markdown
Member

@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. 🤷‍♂

@sparrowDom

Copy link
Copy Markdown
Member Author

Yeah it was the simplest solution. Happy to change it to something else if need/wish be.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants