Skip to content

Commit

Permalink
fix: the NFT reward bottom sheet unexpectedly reappears after CTA but…
Browse files Browse the repository at this point in the history
…ton is pressed (#5076)

### Description

On the iOS production build the NFT reward bottom sheet unexpectedly
reappears after CTA button is pressed.
The hypothesis is that `onChange` event isn't fired for some reason when
the bottom sheet is closed programmatically.

The fix is to fire `dispatch` on CTA press handler instead of relying on
`onChange` event.

Another possible option is to rely on `onClose` event. But unfortunately
it is called when component unmounts on Android.

### Test plan

Tested manually on:
* Android emulator
* iOS simulator
* dev iOS build on device

Planing to additionally test on the nightly iOS build.

### Related issues

- Related to  RET-1002

### Backwards compatibility

Y

### Network scalability

NA
  • Loading branch information
bakoushin committed Mar 12, 2024
1 parent a658959 commit 4d484cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/home/celebration/NftReward.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Provider } from 'react-redux'
import { HomeEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import { openDeepLink } from 'src/app/actions'
import { nftRewardDisplayed } from 'src/home/actions'
import { getFeatureGate } from 'src/statsig/index'
import Colors from 'src/styles/colors'
import { createMockStore } from 'test/utils'
Expand Down Expand Up @@ -42,6 +43,8 @@ describe('NftReward', () => {
openDeepLink(mockStoreRewardReady.home.nftCelebration.deepLink, true)
)

expect(store.dispatch).toHaveBeenCalledWith(nftRewardDisplayed())

expect(ValoraAnalytics.track).toHaveBeenCalledWith(HomeEvents.nft_reward_accept, {
networkId: mockNftAllFields.networkId,
contractAddress: mockNftAllFields.contractAddress,
Expand Down
14 changes: 8 additions & 6 deletions src/home/celebration/NftReward.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ export default function NftRewardBottomSheet() {
contractAddress: nftCelebration.contractAddress,
remainingDays: differenceInDays(rewardExpirationDate, Date.now()),
})
}

dispatch(nftRewardDisplayed())
dispatch(nftRewardDisplayed())
}
}
}

Expand All @@ -100,14 +100,16 @@ export default function NftRewardBottomSheet() {
remainingDays: differenceInDays(rewardExpirationDate, Date.now()),
})

setRewardAccepted(true)

bottomSheetRef.current?.close()

if (nftCelebration?.deepLink) {
const isSecureOrigin = true
dispatch(openDeepLink(nftCelebration.deepLink, isSecureOrigin))
}

setRewardAccepted(true)

bottomSheetRef.current?.close()

dispatch(nftRewardDisplayed())
}

if (!isVisible) {
Expand Down

0 comments on commit 4d484cf

Please sign in to comment.