Skip to content

Commit

Permalink
Only run "disable min shell on foregrounding" behaviour if on the hom…
Browse files Browse the repository at this point in the history
…e screen (#3825)

* change useEffect to useFocusEffect

* v2 -> v3
  • Loading branch information
mozzius authored May 2, 2024
1 parent 96c5db3 commit 6da18e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/lib/statsig/gates.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type Gate =
// Keep this alphabetic please.
| 'autoexpand_suggestions_on_profile_follow_v2'
| 'disable_min_shell_on_foregrounding_v2'
| 'disable_min_shell_on_foregrounding_v3'
| 'disable_poll_on_discover_v2'
| 'dms'
| 'hide_vertical_scroll_indicators'
Expand Down
30 changes: 16 additions & 14 deletions src/view/screens/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,24 @@ function HomeScreenReady({
const gate = useGate()
const mode = useMinimalShellMode()
const {isMobile} = useWebMediaQueries()
React.useEffect(() => {
const listener = AppState.addEventListener('change', nextAppState => {
if (nextAppState === 'active') {
if (
isMobile &&
mode.value === 1 &&
gate('disable_min_shell_on_foregrounding_v2')
) {
setMinimalShellMode(false)
useFocusEffect(
React.useCallback(() => {
const listener = AppState.addEventListener('change', nextAppState => {
if (nextAppState === 'active') {
if (
isMobile &&
mode.value === 1 &&
gate('disable_min_shell_on_foregrounding_v3')
) {
setMinimalShellMode(false)
}
}
})
return () => {
listener.remove()
}
})
return () => {
listener.remove()
}
}, [setMinimalShellMode, mode, isMobile, gate])
}, [setMinimalShellMode, mode, isMobile, gate]),
)

const onPageSelected = React.useCallback(
(index: number) => {
Expand Down

0 comments on commit 6da18e3

Please sign in to comment.