Skip to content

Jon/fix/coinrank-loading #5544

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Jon/fix/coinrank-loading #5544

wants to merge 3 commits into from

Conversation

Jon-edge
Copy link
Collaborator

@Jon-edge Jon-edge commented Apr 23, 2025

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

Comment on lines 145 to 153
if (lastSceneFiat !== coingeckoFiat) {
// Clear cache if we changed the fiat while outside of this scene
debugLog(LOG_COINRANK, 'Clearing coinRankingDatas cache')
coinRanking.coinRankingDatas = []
lastStartIndex.current = 1
setDataSize(0)
setRequestDataSize(QUERY_PAGE_SIZE)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just put this in useMount hook?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See comment
#5544 (comment)

We need to pass mounted.current around separately anyway, so might as well fold
the changes into this existing effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using useMount for the purpose of avoid the eslint-disable-next-line rule hack

}
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this // eslint-disable-next-line react-hooks/exhaustive-deps added? Is there an alternative?

Copy link
Collaborator Author

@Jon-edge Jon-edge Apr 24, 2025

Choose a reason for hiding this comment

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

This was the cause of the actual bug in the task - this cleanup fn is appropriate only for when the scene is still mounted, implying that the fiat changed while the scene was mounted, so clearing everything was appropriate.

It's inappropriate to run this cleanup when the scene unmounts, which was happening in the original implementation. We lose the cache in that case, which defeats the purpose of the cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for the eslint-disable-next-line rule hack though? Seeing this hack is a red flag. I'm trying to understand why it's necessary and perhaps why another approach wasn't taken.

Comment on lines +157 to +159
// Queries should update this, but just in case:
lastSceneFiat = coingeckoFiat
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not put this in a useUnmount hook?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See comment
#5544 (comment)

We need to pass mounted.current around separately anyway, so might as well fold
the changes into this existing effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why I suggest useUnmount is to avoid the disabled eslint rule hack.

This also requires keeping track of the scene's last known fiat in case it changes while the scene is unmounted, which should result in a clearing of the cache.
@Jon-edge Jon-edge force-pushed the jon/fix/coinrank-loading branch from 7539af4 to e954364 Compare April 26, 2025 00:49
@Jon-edge Jon-edge force-pushed the jon/fix/coinrank-loading branch from e954364 to 7c1c8d7 Compare April 26, 2025 01:10
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.

2 participants