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(cash-in-bottom-sheet): only show when home is in focus #3927

Closed
wants to merge 4 commits into from

Conversation

MuckT
Copy link
Collaborator

@MuckT MuckT commented Jun 29, 2023

Description

Makes is so the cash in bottom sheet is only displayed when the wallethome.tsx is in focus and re-enables the fiat connect cash out tests: Related Slack Thread.

Test plan

Tested locally on Android after the tests are enabled.

Related issues

Backwards compatibility

Yes

Comment on lines 120 to 122
if (!isFocused) {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

one side effect of this change is that the bottom sheet will now appear every time the home screen gets back focus and the other conditions satisfy, whereas previously it appears only once on app load and then later only once when the balance goes from non zero to zero. I believe this is tracked by local state and this state is kept in memory as long as the conditions to show / not show never changes. With this change though, I believe we lose this state every time focus changes.

Copy link
Collaborator Author

@MuckT MuckT Jun 29, 2023

Choose a reason for hiding this comment

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

🤔 We could move the cash-in bottom sheet into redux state and dispatch it similar to to the in-app review. That way we only dispatch it on an app action we want such as Actions.SET_ACCOUNT.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@satish-ravi I ended up wrapping the component in a useMemo which seems to do the trick in 500d92f. I'll test a bit more and confirm things are WAI.

@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Merging #3927 (cf9fb5d) into main (a6f8313) will increase coverage by 0.00%.
The diff coverage is 88.23%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3927   +/-   ##
=======================================
  Coverage   82.27%   82.28%           
=======================================
  Files         708      708           
  Lines       26289    26292    +3     
  Branches     3584     3582    -2     
=======================================
+ Hits        21629    21634    +5     
+ Misses       4597     4595    -2     
  Partials       63       63           
Impacted Files Coverage Δ
src/home/WalletHome.tsx 96.29% <88.23%> (-0.85%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

Comment on lines +171 to +173
const WrappedCashInBottomSheet = useMemo(() => {
if (!isFocused) {
return null
Copy link
Member

Choose a reason for hiding this comment

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

This feels a bit too hacky, since isFocused is not in the list of dependencies for useMemo.

Could we instead keep the old implementation and track (via some state) whether we've already displayed the bottom sheet to avoid triggering it every time the screen is put in focus?

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 also want to ensure that the bottom sheet will only appear a single time per app session; that is, I think the semantics should be:

  • Show the bottom sheet once per app session, on the first occurrence of the following conditions:
    • Bottom sheet is enabled
    • User has zero balance
    • Home screen is focused

Namely, we want to avoid showing the bottom sheet multiple times in the situation where a user goes from zero balance -> nonzero balance -> zero balance, all within the same app session.

@MuckT MuckT closed this Jul 7, 2023
@MuckT MuckT deleted the tomm/cashin-bottom-sheet-fix branch March 7, 2024 23:52
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.

4 participants