add feature gate
This commit is contained in:
@@ -23,6 +23,7 @@ import {HITSLOP_10} from '#/lib/constants'
|
|||||||
import {usePalette} from '#/lib/hooks/usePalette'
|
import {usePalette} from '#/lib/hooks/usePalette'
|
||||||
import {MagnifyingGlassIcon} from '#/lib/icons'
|
import {MagnifyingGlassIcon} from '#/lib/icons'
|
||||||
import {NavigationProp} from '#/lib/routes/types'
|
import {NavigationProp} from '#/lib/routes/types'
|
||||||
|
import {useGate} from '#/lib/statsig/statsig'
|
||||||
import {augmentSearchQuery} from '#/lib/strings/helpers'
|
import {augmentSearchQuery} from '#/lib/strings/helpers'
|
||||||
import {s} from '#/lib/styles'
|
import {s} from '#/lib/styles'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
@@ -197,7 +198,7 @@ function SearchScreenPostResults({
|
|||||||
sort,
|
sort,
|
||||||
}: {
|
}: {
|
||||||
query: string
|
query: string
|
||||||
sort: 'top' | 'latest'
|
sort?: 'top' | 'latest'
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
@@ -325,12 +326,16 @@ function SearchScreenUserResults({query}: {query: string}) {
|
|||||||
|
|
||||||
const SECTIONS_LOGGEDOUT = ['PEOPLE'] as const
|
const SECTIONS_LOGGEDOUT = ['PEOPLE'] as const
|
||||||
const SECTIONS_LOGGEDIN = ['TOP', 'LATEST', 'PEOPLE'] as const
|
const SECTIONS_LOGGEDIN = ['TOP', 'LATEST', 'PEOPLE'] as const
|
||||||
|
const SECTIONS_LOGGEDOUT_LEGACY = ['USERS'] as const
|
||||||
|
const SECTIONS_LOGGEDIN_LEGACY = ['POSTS', 'USERS'] as const
|
||||||
|
|
||||||
function getSectionName(
|
function getSectionName(
|
||||||
i18n: I18n,
|
i18n: I18n,
|
||||||
section:
|
section:
|
||||||
| (typeof SECTIONS_LOGGEDIN)[number]
|
| (typeof SECTIONS_LOGGEDIN)[number]
|
||||||
| (typeof SECTIONS_LOGGEDOUT)[number],
|
| (typeof SECTIONS_LOGGEDOUT)[number]
|
||||||
|
| (typeof SECTIONS_LOGGEDIN_LEGACY)[number]
|
||||||
|
| (typeof SECTIONS_LOGGEDOUT_LEGACY)[number],
|
||||||
) {
|
) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 'TOP':
|
case 'TOP':
|
||||||
@@ -339,6 +344,10 @@ function getSectionName(
|
|||||||
return i18n._(msg`Latest`)
|
return i18n._(msg`Latest`)
|
||||||
case 'PEOPLE':
|
case 'PEOPLE':
|
||||||
return i18n._(msg`People`)
|
return i18n._(msg`People`)
|
||||||
|
case 'POSTS':
|
||||||
|
return i18n._(msg`Posts`)
|
||||||
|
case 'USERS':
|
||||||
|
return i18n._(msg`Users`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,6 +365,9 @@ export function SearchScreenInner({
|
|||||||
const {isDesktop} = useWebMediaQueries()
|
const {isDesktop} = useWebMediaQueries()
|
||||||
const {i18n} = useLingui()
|
const {i18n} = useLingui()
|
||||||
|
|
||||||
|
// New Search feature gate
|
||||||
|
const isNewSearch = useGate('new_search')
|
||||||
|
|
||||||
const onPageSelected = React.useCallback(
|
const onPageSelected = React.useCallback(
|
||||||
(index: number) => {
|
(index: number) => {
|
||||||
setMinimalShellMode(false)
|
setMinimalShellMode(false)
|
||||||
@@ -364,7 +376,13 @@ export function SearchScreenInner({
|
|||||||
[setDrawerSwipeDisabled, setMinimalShellMode],
|
[setDrawerSwipeDisabled, setMinimalShellMode],
|
||||||
)
|
)
|
||||||
|
|
||||||
const sections = hasSession ? SECTIONS_LOGGEDIN : SECTIONS_LOGGEDOUT
|
const sections = React.useMemo(() => {
|
||||||
|
if (isNewSearch) {
|
||||||
|
return hasSession ? SECTIONS_LOGGEDIN : SECTIONS_LOGGEDOUT
|
||||||
|
} else {
|
||||||
|
return hasSession ? SECTIONS_LOGGEDIN_LEGACY : SECTIONS_LOGGEDOUT_LEGACY
|
||||||
|
}
|
||||||
|
}, [hasSession, isNewSearch])
|
||||||
|
|
||||||
const tabBarItems = React.useMemo(
|
const tabBarItems = React.useMemo(
|
||||||
() => sections.map(section => getSectionName(i18n, section)),
|
() => sections.map(section => getSectionName(i18n, section)),
|
||||||
@@ -383,12 +401,20 @@ export function SearchScreenInner({
|
|||||||
</CenteredView>
|
</CenteredView>
|
||||||
)}
|
)}
|
||||||
initialPage={0}>
|
initialPage={0}>
|
||||||
<View>
|
{isNewSearch ? (
|
||||||
<SearchScreenPostResults query={query} sort="top" />
|
<>
|
||||||
</View>
|
<View>
|
||||||
<View>
|
<SearchScreenPostResults query={query} sort="top" />
|
||||||
<SearchScreenPostResults query={query} sort="latest" />
|
</View>
|
||||||
</View>
|
<View>
|
||||||
|
<SearchScreenPostResults query={query} sort="latest" />
|
||||||
|
</View>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<View>
|
||||||
|
<SearchScreenPostResults query={query} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
<View>
|
<View>
|
||||||
<SearchScreenUserResults query={query} />
|
<SearchScreenUserResults query={query} />
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user