-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(IT Wallet): [SIW-1852] Hide discovery banner after close (#6499)
## Short description This PR hides the discovery banner in the messages screen for six months after the user closes it. Note that only the closable banner in the messages screen stays hidden, the one in the wallet screen is always visible. ## List of changes proposed in this pull request - Added `hideDiscoveryBannerUntilDate` key to the `preferences` reducer - Changed the selector in `landingScreenBannerMap` ## How to test - Close the discovery banner in the messages screen and reload the app: it should be visible anymore - Ensure the discovery banner in the wallet screen is still visible --------- Co-authored-by: Federico Mastrini <[email protected]>
- Loading branch information
Showing
10 changed files
with
97 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 16 additions & 36 deletions
52
ts/features/itwallet/common/components/discoveryBanner/ItwDiscoveryBannerStandalone.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,32 @@ | ||
import React, { ReactElement } from "react"; | ||
import { View } from "react-native"; | ||
import React from "react"; | ||
import { StyleSheet, View } from "react-native"; | ||
import { useIOSelector } from "../../../../../store/hooks"; | ||
import { isItwDiscoveryBannerRenderableSelector } from "../../store/selectors"; | ||
import { | ||
ItwDiscoveryBanner, | ||
ItwDiscoveryBannerProps | ||
} from "./ItwDiscoveryBanner"; | ||
|
||
type Props = Omit<ItwDiscoveryBannerProps, "handleOnClose"> & { | ||
fallbackComponent?: ReactElement; | ||
}; | ||
import { ItwDiscoveryBanner } from "./ItwDiscoveryBanner"; | ||
|
||
/** | ||
* to use in flows where either | ||
* - we need a fallback component | ||
* - we do not want to handle the banner's visibility logic externally | ||
* (see MultiBanner feature for the landing screen) | ||
* to use in flows where we do not want to handle the banner's visibility logic externally | ||
* (see MultiBanner feature for the landing screen) | ||
*/ | ||
export const ItwDiscoveryBannerStandalone = (props: Props) => { | ||
const [isVisible, setVisible] = React.useState(true); | ||
|
||
export const ItwDiscoveryBannerStandalone = () => { | ||
const isBannerRenderable = useIOSelector( | ||
isItwDiscoveryBannerRenderableSelector | ||
); | ||
|
||
const shouldBeHidden = React.useMemo( | ||
() => | ||
// Banner should be hidden if: | ||
!isVisible || // The user closed it by pressing the `x` button | ||
!isBannerRenderable, // the various validity checks fail | ||
[isBannerRenderable, isVisible] | ||
); | ||
|
||
if (shouldBeHidden) { | ||
const { fallbackComponent } = props; | ||
if (fallbackComponent) { | ||
return fallbackComponent; | ||
} | ||
if (!isBannerRenderable) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<View style={{ marginTop: 16, marginBottom: 8 }}> | ||
<ItwDiscoveryBanner | ||
ignoreMargins={true} | ||
handleOnClose={() => setVisible(false)} | ||
{...props} | ||
/> | ||
<View style={styles.wrapper}> | ||
<ItwDiscoveryBanner ignoreMargins={true} closable={false} /> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
wrapper: { | ||
marginTop: 16, | ||
marginBottom: 8 | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters