-
Notifications
You must be signed in to change notification settings - Fork 295
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
[DDW-360] Transactions paging #1078
Conversation
source/renderer/app/api/ada/index.js
Outdated
|
||
// In case there is more than one page, | ||
// it loops through them and adds to the `history` array | ||
if (totalPages > 1) { |
There was a problem hiding this comment.
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
source/renderer/app/api/ada/types.js
Outdated
data: Array<AdaTransactionV1>, | ||
meta: { | ||
pagination: { | ||
totalPages: number, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarcusHurney great. @nikolaglumac done.
There was a problem hiding this 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.
@DominikGuzei please review this one as this is quite important change! Thanks! |
…0-transactions-paging
…0-transactions-paging
There was a problem hiding this 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
|
||
// In case there is more than one page, | ||
// it loops through them and adds to the `history` array | ||
if (totalPages > 1 && limit > 50) { |
There was a problem hiding this comment.
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)
source/renderer/app/api/ada/index.js
Outdated
// 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++) { |
There was a problem hiding this comment.
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
@DominikGuzei thanks for the great suggestions. |
This PR implements the transactions history paging.
Todo:
totalPages
to request the transactions from the next pageslimit
paramObs.: It's possible to test the pagination by hardcoding the
perPage
variable to 1:if (perPage === 50) perPage = 1;
Review Checklist:
Basics
yarn run test
)yarn run dev
)yarn run package
/ CI builds)yarn run flow:test
)yarn run lint
)yarn run manage:translations
produces no changes)yarn run storybook
)yarn.lock
file is updatedCode Quality
Testing
After Review:
done
on the Youtrack board