[Statsig] Make gate checks lazily (#3594)
This commit is contained in:
parent
086dc93a7a
commit
02becdf449
14 changed files with 67 additions and 62 deletions
|
@ -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) => {
|
||||
|
|
|
@ -38,8 +38,7 @@ export function ModerationBlockedAccounts({}: Props) {
|
|||
const setMinimalShellMode = useSetMinimalShellMode()
|
||||
const {isTabletOrDesktop} = useWebMediaQueries()
|
||||
const {screen} = useAnalytics()
|
||||
const showsVerticalScrollIndicator =
|
||||
!useGate('hide_vertical_scroll_indicators') || isWeb
|
||||
const gate = useGate()
|
||||
|
||||
const [isPTRing, setIsPTRing] = React.useState(false)
|
||||
const {
|
||||
|
@ -169,7 +168,9 @@ export function ModerationBlockedAccounts({}: Props) {
|
|||
)}
|
||||
// @ts-ignore our .web version only -prf
|
||||
desktopFixedHeight
|
||||
showsVerticalScrollIndicator={showsVerticalScrollIndicator}
|
||||
showsVerticalScrollIndicator={
|
||||
isWeb || !gate('hide_vertical_scroll_indicators')
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</CenteredView>
|
||||
|
|
|
@ -38,8 +38,8 @@ export function ModerationMutedAccounts({}: Props) {
|
|||
const setMinimalShellMode = useSetMinimalShellMode()
|
||||
const {isTabletOrDesktop} = useWebMediaQueries()
|
||||
const {screen} = useAnalytics()
|
||||
const showsVerticalScrollIndicator =
|
||||
!useGate('hide_vertical_scroll_indicators') || isWeb
|
||||
const gate = useGate()
|
||||
|
||||
const [isPTRing, setIsPTRing] = React.useState(false)
|
||||
const {
|
||||
data,
|
||||
|
@ -167,7 +167,9 @@ export function ModerationMutedAccounts({}: Props) {
|
|||
)}
|
||||
// @ts-ignore our .web version only -prf
|
||||
desktopFixedHeight
|
||||
showsVerticalScrollIndicator={showsVerticalScrollIndicator}
|
||||
showsVerticalScrollIndicator={
|
||||
isWeb || !gate('hide_vertical_scroll_indicators')
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</CenteredView>
|
||||
|
|
|
@ -143,7 +143,7 @@ function ProfileScreenLoaded({
|
|||
const setMinimalShellMode = useSetMinimalShellMode()
|
||||
const {openComposer} = useComposerControls()
|
||||
const {screen, track} = useAnalytics()
|
||||
const shouldUseScrollableHeader = useGate('new_profile_scroll_component')
|
||||
const gate = useGate()
|
||||
const {
|
||||
data: labelerInfo,
|
||||
error: labelerError,
|
||||
|
@ -317,7 +317,7 @@ function ProfileScreenLoaded({
|
|||
// =
|
||||
|
||||
const renderHeader = React.useCallback(() => {
|
||||
if (shouldUseScrollableHeader) {
|
||||
if (gate('new_profile_scroll_component')) {
|
||||
return (
|
||||
<ExpoScrollForwarderView scrollViewTag={scrollViewTag}>
|
||||
<ProfileHeader
|
||||
|
@ -343,7 +343,7 @@ function ProfileScreenLoaded({
|
|||
)
|
||||
}
|
||||
}, [
|
||||
shouldUseScrollableHeader,
|
||||
gate,
|
||||
scrollViewTag,
|
||||
profile,
|
||||
labelerInfo,
|
||||
|
|
|
@ -210,7 +210,8 @@ function useSuggestedFollowsV2(): [
|
|||
|
||||
function SearchScreenSuggestedFollows() {
|
||||
const pal = usePalette('default')
|
||||
const useSuggestedFollows = useGate('use_new_suggestions_endpoint')
|
||||
const gate = useGate()
|
||||
const useSuggestedFollows = gate('use_new_suggestions_endpoint')
|
||||
? // Conditional hook call here is *only* OK because useGate()
|
||||
// result won't change until a remount.
|
||||
useSuggestedFollowsV2
|
||||
|
@ -406,8 +407,7 @@ export function SearchScreenInner({
|
|||
const {isDesktop} = useWebMediaQueries()
|
||||
const [activeTab, setActiveTab] = React.useState(0)
|
||||
const {_} = useLingui()
|
||||
|
||||
const isNewSearch = useGate('new_search')
|
||||
const gate = useGate()
|
||||
|
||||
const onPageSelected = React.useCallback(
|
||||
(index: number) => {
|
||||
|
@ -420,7 +420,7 @@ export function SearchScreenInner({
|
|||
|
||||
const sections = React.useMemo(() => {
|
||||
if (!query) return []
|
||||
if (isNewSearch) {
|
||||
if (gate('new_search')) {
|
||||
if (hasSession) {
|
||||
return [
|
||||
{
|
||||
|
@ -487,7 +487,7 @@ export function SearchScreenInner({
|
|||
]
|
||||
}
|
||||
}
|
||||
}, [hasSession, isNewSearch, _, query, activeTab])
|
||||
}, [hasSession, gate, _, query, activeTab])
|
||||
|
||||
if (hasSession) {
|
||||
return query ? (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue