Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow short token URLs #1962

Merged
merged 3 commits into from
Jun 2, 2020
Merged

Allow short token URLs #1962

merged 3 commits into from
Jun 2, 2020

Conversation

amass01
Copy link
Member

@amass01 amass01 commented May 29, 2020

This diff allows users to use short proposal's token in URLs - first 7 chars of original 64 chars hex.

Solution description

  • Adjusted useProposal hook to fetch voteSummary only when full token is fetched and stored in redux store.
  • Updated makeGetProposalByToken selector to try find the stored proposal by using the 7 chars prefix instead of full length token.
  • Updated useProposalURLs hook to use prefix instead of full token to struct proposal URLs.
  • Updated ProposalForm submit handler to use short token when navigating to proposal details after successful edit/create.

Dependencies

Closes #1939

@amass01 amass01 changed the title [wip] Allow short token URLs Allow short token URLs May 30, 2020
Copy link
Member

@tiagoalvesdulce tiagoalvesdulce left a comment

Choose a reason for hiding this comment

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

Code is looking good. I noticed that edit proposals is still redirecting to the full token URL. Can we use short token URLs there too?

@amass01
Copy link
Member Author

amass01 commented Jun 2, 2020

@tiagoalvesdulce Intended mate, BE edit route need the full token so I kept it as is in that case - when edit is done I do use the short token when redirecting the user to proposal's details page

Copy link
Member

@victorgcramos victorgcramos left a comment

Choose a reason for hiding this comment

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

Code looking good! Left only one inline comment. It is just a doubt :D

@@ -27,19 +26,6 @@ export const getStatusBarData = (voteSummary) => {
.sort((a) => (a.label === "yes" ? -1 : 1));
};

export const getProposalUrl = (token, javascriptEnabled) =>
Copy link
Member

Choose a reason for hiding this comment

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

Is there any specific reason for removing this piece of code?

Copy link
Member Author

@amass01 amass01 Jun 2, 2020

Choose a reason for hiding this comment

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

hehe sure, it's just a cleanup at some point we created useProposalURLs hook and it uses the same functions which are defined in https://github.com/amassarwi/politeiagui/blob/tokenPrefix/src/containers/Proposal/helpers.js#L225-L236

Copy link
Member Author

Choose a reason for hiding this comment

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

image

Copy link
Member

Choose a reason for hiding this comment

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

oh good! Thanks! haha

@tiagoalvesdulce tiagoalvesdulce merged commit c416b15 into decred:master Jun 2, 2020
@amass01 amass01 deleted the tokenPrefix branch December 17, 2020 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow short token URLs
3 participants