[Statsig] Make gate checks lazily (#3594)

This commit is contained in:
dan
2024-04-18 04:39:29 +01:00
committed by GitHub
parent 086dc93a7a
commit 02becdf449
14 changed files with 67 additions and 62 deletions
+9 -10
View File
@@ -111,21 +111,20 @@ function HomeScreenReady({
}),
)
const disableMinShellOnForegrounding = useGate(
'disable_min_shell_on_foregrounding',
)
const gate = useGate()
React.useEffect(() => {
if (disableMinShellOnForegrounding) {
const listener = AppState.addEventListener('change', nextAppState => {
if (nextAppState === 'active') {
const listener = AppState.addEventListener('change', nextAppState => {
if (nextAppState === 'active') {
// TODO: Check if minimal shell is on before logging an exposure.
if (gate('disable_min_shell_on_foregrounding')) {
setMinimalShellMode(false)
}
})
return () => {
listener.remove()
}
})
return () => {
listener.remove()
}
}, [setMinimalShellMode, disableMinShellOnForegrounding])
}, [setMinimalShellMode, gate])
const onPageSelected = React.useCallback(
(index: number) => {