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

[DDW-360] Transactions paging #1078

Conversation

thedanheller
Copy link
Contributor

@thedanheller thedanheller commented Sep 4, 2018

This PR implements the transactions history paging.

Todo:

  • Get the meta information from the Request V1
  • Loop through the totalPages to request the transactions from the next pages
  • Limit the pages based on the limit param

Obs.: It's possible to test the pagination by hardcoding the perPage variable to 1:
if (perPage === 50) perPage = 1;


Review Checklist:

Basics

  • PR is updated to the most recent version of target branch (and there are no conflicts)
  • PR has good description that summarizes all changes and shows some screenshots or animated GIFs of important UI changes
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub
  • Automated tests: All acceptance tests are passing (yarn run test)
  • Manual tests (minimum tests should cover newly added feature/fix): App works correctly in development build (yarn run dev)
  • Manual tests (minimum tests should cover newly added feature/fix): App works correctly in production build (yarn run package / CI builds)
  • There are no flow errors or warnings (yarn run flow:test)
  • There are no lint errors or warnings (yarn run lint)
  • Text changes are proofread and approved (Jane Wild)
  • There are no missing translations (running yarn run manage:translations produces no changes)
  • UI changes look good in all themes (Alexander Rukin)
  • Storybook works and no stories are broken (yarn run storybook)
  • In case of dependency changes yarn.lock file is updated

Code Quality

  • Important parts of the code are properly documented and commented
  • Code is properly typed with flow
  • React components are split-up enough to avoid unnecessary re-rendering
  • Any code that only works in Electron is neatly separated from components

Testing

  • New feature / change is covered by acceptance tests
  • All existing acceptance tests are still up-to-date
  • New feature / change is covered by Daedalus Testing scenario
  • All existing Daedalus Testing scenarios are still up-to-date

After Review:

  • Merge PR
  • Delete source branch
  • Move ticket to done on the Youtrack board


// In case there is more than one page,
// it loops through them and adds to the `history` array
if (totalPages > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@daniloprates in case we need just 5 transactions we don’t need to fetch more than 1 page

data: Array<AdaTransactionV1>,
meta: {
pagination: {
totalPages: number,
Copy link
Contributor

Choose a reason for hiding this comment

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

@daniloprates please add the types for all other possible meta data props from the docs

Copy link
Contributor

@MarcusHurney MarcusHurney Sep 6, 2018

Choose a reason for hiding this comment

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

@daniloprates
I’ve got a type for meta data. You can get the entirety as ResponseBaseV1 or Pagination if you just want that. They are at the bottom of api/ada/types.js

Copy link
Contributor

Choose a reason for hiding this comment

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

@daniloprates can you please check this out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@nikolaglumac nikolaglumac left a comment

Choose a reason for hiding this comment

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

Great work @daniloprates!
I have left some comments we need to resolve before merging.

@thedanheller
Copy link
Contributor Author

@nikolaglumac

@nikolaglumac
Copy link
Contributor

@DominikGuzei please review this one as this is quite important change! Thanks!

Copy link
Member

@DominikGuzei DominikGuzei left a comment

Choose a reason for hiding this comment

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

Great work 🎉
I just added a few notes for improving the readability of this code!

source/renderer/app/api/ada/index.js Outdated Show resolved Hide resolved

// In case there is more than one page,
// it loops through them and adds to the `history` array
if (totalPages > 1 && limit > 50) {
Copy link
Member

Choose a reason for hiding this comment

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

You could remove the comment by using a descriptive var like const hasMultiplePages = (totalPages > 1 && limit > perPage) in the conditional instead of explaining what the expression does 😉

(in general if you find yourself explaining simple things like this in comments, try to find a more descriptive way to express the same idea in code)

// In case there is more than one page,
// it loops through them and adds to the `history` array
if (totalPages > 1 && limit > 50) {
for (let page = 2; (page < totalPages + 1 && page <= pageLimit); page++) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here, there is too much going on in this loop condition … you could simplify the condition by introducing two vars const hasNextPage = page < totalPages + 1 and const shouldLoadNextPage = page <= pageLimit

@thedanheller thedanheller removed the WIP label Sep 10, 2018
@thedanheller
Copy link
Contributor Author

@DominikGuzei thanks for the great suggestions.
@nikolaglumac limitless calls also available.

@nikolaglumac nikolaglumac merged commit 6b66f67 into feature/ddw-321-v1-api-integration Sep 11, 2018
@nikolaglumac nikolaglumac deleted the feature/ddw-360-transactions-paging branch September 11, 2018 09:09
This was referenced Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants