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

[Wallet] Fix last alert banner redisplayed on re-render #6325

Merged
merged 3 commits into from
Dec 22, 2020

Conversation

jeanregisser
Copy link
Contributor

@jeanregisser jeanregisser commented Dec 22, 2020

Description

This fixes the regression described in #6314.

The change in #6230 made the underlying problem in AlertBanner more prominent as it caused the top level navigator to re-render on app state change (background/foreground/inactive) and hence the AlertBanner.

Other changes

Globally mock Animated.View and Animated.ScrollView to prevent out of memory error when a ref is set.
See callstack/react-native-testing-library#539

Note: This change caused the Snapshot updates, because the styles are not flattened anymore for the mocked Animated.View.

Tested

  • Last alert is not redisplayed when navigating to different screens.
  • New alert banner with same content can still be redisplayed when dispatched (causing a state change).

Related issues

Backwards compatibility

Yes

@jeanregisser jeanregisser changed the title [Wallet] Fix alert banner redisplayed on re-render [Wallet] Fix last alert banner redisplayed on re-render Dec 22, 2020
@jeanregisser jeanregisser requested a review from a team December 22, 2020 14:14
Copy link
Contributor

@gnardini gnardini left a comment

Choose a reason for hiding this comment

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

Changes look good to me, but I'm not sure I see why the alert would re-render if hideAlert was already called in the past. I noticed the timestamp being passed, but feel like I'm missing some interaction.

I'm also still not completely clear on something, if the alert has an action, and that action doesn't hide the alert, the alert would not go away, right?

@jeanregisser
Copy link
Contributor Author

What happens is hideAlert is only called if the user actually dismisses the alert by touching it. But visually the alert is being hidden anyway after 5 secs (or never if no dismissAfter is set).
Now you might ask why? If I remember correctly I did it this way because SmartTopAlert takes a single onPress and I didn't want to trigger it if the user didn't actually press it.

Now about your 2nd question, the alert state is cleared when the alert action is dispatched and hence dismisses the banner.
See

if (state?.action === action) {
// Hide alert when the alert action is dispatched
return null
}

Copy link
Contributor

@gnardini gnardini left a comment

Choose a reason for hiding this comment

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

That makes sense, thanks for explaining, I saw the default in the reducer but didn't connect the dots.

I think it would be clearer/nice if after the 5 seconds the hide action was fired anyways. There's no reason I can think of to still have the action in the store if we never plan on showing it again and it can lead to this sort of bugs and having two different sources of truth makes it less clear imo (the state of the smart banner and the redux store).

Anyways, no need to change anything here, LGTM, just sharing my thoughts 😄

@jeanregisser
Copy link
Contributor Author

jeanregisser commented Dec 22, 2020

Yes we can revisit this later, this somewhat odd design was because of the separation between SmartTopAlert (no access to redux, since it's in react-components) and AlertBanner (within the app).
Which doesn't make sense anymore.

@jeanregisser jeanregisser added the automerge Have PR merge automatically when checks pass label Dec 22, 2020
@mergify mergify bot merged commit d8bee97 into master Dec 22, 2020
@mergify mergify bot deleted the jeanregisser/fix-alert-banner-redisplayed branch December 22, 2020 16:12
@Lss-Ankit
Copy link

Hi @jeanregisser we have verified this issue on latest latest Android internal build V1.7.2(1004294329) &Test Flight build V1.7.2(39) and observe the following

  • "Received dollar Blue banner" is not shown when user navigating to different screens Or open app from background

Device: iPhone 6+ (12.4.5). Vivo V11 pro (10)

Can you please let us know if we need to test anything else in this task

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 wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Previous error banner displayed when navigating to different screens
4 participants