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

fix(homefeed): ensure that users can scroll to load more #2779

Merged
merged 11 commits into from
Aug 12, 2022

Conversation

kathaypacific
Copy link
Collaborator

@kathaypacific kathaypacific commented Aug 11, 2022

Description

Context: https://valora-app.slack.com/archives/C018VLA3YAK/p1660091022594799

The solution chosen for this issue is to continue to fetch transactions from the client until a minimum threshold is met (currently 10) so that the section list is filled and the user can scroll to load more.

In this PR:

  • To ensure no weird bugs and avoid concurrency issues, i refactored the state variables to keep the cumulative transactions + pageInfo in the same state variable so that they are always in sync.
  • Added a hook to refetch transactions until we have 10, and refetch transactions if the returned page is empty
  • Updated tests

Other changes

N/A

Tested

Manually and with unit tests

How others should test

Please try this with many accounts that have varying number of transactions - load the app (from a fresh install, and from cold start) and ensure that the home feed displays transactions. If the account has many transactions, ensure that you can scroll down to load more transactions.

Related issues

N/A

Backwards compatibility

Yes

if (!paginatedResult) {
setFetchedResult((prev) => ({
transactions: deduplicateTransactions(prev.transactions, returnedTransactions),
pageInfo: returnedPageInfo ?? null,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dievazqu this is one part of the logic that i changed (compared to line 94 from the previous version), can you think of any places where this condition is not okay? for the few cases i tested, this works okay

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems ok!

@codecov
Copy link

codecov bot commented Aug 11, 2022

Codecov Report

Merging #2779 (5f42507) into main (1922a6c) will increase coverage by 0.01%.
The diff coverage is 95.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2779      +/-   ##
==========================================
+ Coverage   79.74%   79.75%   +0.01%     
==========================================
  Files         600      600              
  Lines       21729    21739      +10     
  Branches     3948     3958      +10     
==========================================
+ Hits        17327    17338      +11     
+ Misses       4355     4353       -2     
- Partials       47       48       +1     
Impacted Files Coverage Δ
src/transactions/feed/queryHelper.ts 91.76% <95.00%> (+0.85%) ⬆️
src/fiatconnect/ReviewScreen.tsx 80.50% <100.00%> (+0.33%) ⬆️
src/tokens/utils.ts 100.00% <0.00%> (+2.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13be500...5f42507. Read the comment docs.


const returnedTransactions = result.data?.tokenTransactionsV2?.transactions
const returnedPageInfo = result.data?.tokenTransactionsV2?.pageInfo

if (returnedTransactions?.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have to change this...
Because if the returned transactions are empty, but it's not the last page (meaning that hasNextPage is true, but the blockchain-api has filtered out all the unknown transactions), we still have to update fetchedResult.pageInfo so when we query again we get a different page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh excellent point, i can add a check for pageInfo here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed and added a test

Copy link
Contributor

@dievazqu dievazqu left a comment

Choose a reason for hiding this comment

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

LGTM!

@Samuel3Shin
Copy link
Contributor

I tested it with my android emulator (Pixel 2 API 29 / 1080 x 1920: 420dpi / Android 10.0 / x86).
I checked that this branch fixed the not loading transaction feed problem in my android emulator for the two addresses 0xf53a7a9a5de7ce39ef259c86fd6128ed045bf01a, 0x849fa48c8caa2907032f45765d7d6f52da13598d.

dispatch(showError(ErrorMessages.FETCH_FAILED))
} else if (!pageInfo.hasNextPage) {
// If the user has a few transactions, don't show any message
if (transactions.length > 20) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i thought this was an odd requirement so i removed it :/

@kathaypacific kathaypacific added the automerge Have PR merge automatically when checks pass label Aug 12, 2022
@mergify mergify bot merged commit 88fd4a5 into main Aug 12, 2022
@mergify mergify bot deleted the kathy/fix-homefeed-load branch August 12, 2022 13:06
kathaypacific added a commit that referenced this pull request Aug 12, 2022
### Description

Context: https://valora-app.slack.com/archives/C018VLA3YAK/p1660091022594799

The solution chosen for this issue is to continue to fetch transactions from the client until a minimum threshold is met (currently 10) so that the section list is filled and the user can scroll to load more.

In this PR:
- To ensure no weird bugs and avoid concurrency issues, i refactored the state variables to keep the cumulative transactions + pageInfo in the same state variable so that they are always in sync. 
- Added a hook to refetch transactions until we have 10, and refetch transactions if the returned page is empty
- Updated tests

### Other changes

N/A

### Tested

Manually and with unit tests

### How others should test

Please try this with many accounts that have varying number of transactions - load the app (from a fresh install, and from cold start) and ensure that the home feed displays transactions. If the account has many transactions, ensure that you can scroll down to load more transactions.

### Related issues

N/A

### Backwards compatibility

Yes
mergify bot pushed a commit that referenced this pull request Aug 12, 2022
…w transactions (#2783)

### Description

Annoyingly, the `onEndReached` callback is triggered on the SectionList used to render the transaction feed when navigating away from the screen on iOS, when the transaction list is too short. This causes the "no more transactions" toast to appear on the next page that is navigated to, but only once. 

This check for length of transactions used to exist, and I had removed it thinking it was strange #2779 (comment) - but it seems like we need it.

### Other changes

N/A

### Tested

Manually

### How others should test

N/A

### Related issues

N/A

### Backwards compatibility

Yes
kathaypacific added a commit that referenced this pull request Aug 15, 2022
…w transactions (#2783)

### Description

Annoyingly, the `onEndReached` callback is triggered on the SectionList used to render the transaction feed when navigating away from the screen on iOS, when the transaction list is too short. This causes the "no more transactions" toast to appear on the next page that is navigated to, but only once. 

This check for length of transactions used to exist, and I had removed it thinking it was strange #2779 (comment) - but it seems like we need it.

### Other changes

N/A

### Tested

Manually

### How others should test

N/A

### Related issues

N/A

### Backwards compatibility

Yes
@ValoraQA
Copy link

ValoraQA commented Aug 16, 2022

Hey @MuckT, We have verified the above task using Latest Android Internal Release Build, iOS Test Flight Release Build V1.38.2 & observed the following:

  • Latest Transactions in Recent activity section appears fine when user launches app after fresh install, cold launch, kill & relaunch.
  • If the account had many transactions, than user can scroll down to load more transactions in recent activity section when user freshly install, cold launch, kill & relaunch the app.

Devices: Google Pixel XL (10.0), iPhone 13 mini(15.1.1), Google Pixel 4a(12.0)

CC: @kathaypacific
Thanks..!!

@ValoraQA
Copy link

ValoraQA commented Aug 23, 2022

Hey @MuckT we have verified the above task on Latest iOS Test Flight Release build & Android Internal Release Build V 1.39.1 & updated status in Test rails

Observation:

  • Latest Transactions in Recent activity section appears fine when user launches app after fresh install, cold launch, kill & relaunch.
  • If the account has many transactions, than user can scroll down to load more transactions when user performs freshly install, cold launch, kill & relaunching the app.

Test rail link:
iOS 14: https://valoraapp.testrail.io/index.php?/tests/view/61319
Android 12: https://valoraapp.testrail.io/index.php?/tests/view/61304
Android 11: https://valoraapp.testrail.io/index.php?/tests/view/61289

Device : iPhone 12(14.7.1), Google Pixel 4a(12.0), Samsung Galaxy F41(11.0)
CC: @kathaypacific
Thanks.!!

@ValoraQA
Copy link

Hey @MuckT we have verified the above task on Latest iOS Test Flight Release build V 1.39.1 & updated status in Test rails

Observation:

  • Latest Transactions in Recent activity section appears fine when user launches app after fresh install, cold launch, kill & relaunch.
  • If the account has many transactions, than user can scroll down to load more transactions when user performs freshly install, cold launch, kill & relaunching the app.

Test rail link:
iOS 15: https://valoraapp.testrail.io/index.php?/tests/view/61845

Device : iPhone 13 mini(15.1.1)

CC: @kathaypacific

Thanks.!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants