Move /platform/detection vars into /env (#9707)

* Add platform vars to env

* Replace /platform/detection with /env
This commit is contained in:
Eric Bailey
2026-01-16 16:28:17 -06:00
committed by GitHub
parent bd510d8468
commit 0589bd7d9e
244 changed files with 789 additions and 789 deletions
+11 -11
View File
@@ -22,7 +22,6 @@ import {HITSLOP_10} from '#/lib/constants'
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {MagnifyingGlassIcon} from '#/lib/icons'
import {type NavigationProp} from '#/lib/routes/types'
import {isWeb} from '#/platform/detection'
import {listenSoftReset} from '#/state/events'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
import {
@@ -41,6 +40,7 @@ import {Button, ButtonText} from '#/components/Button'
import {SearchInput} from '#/components/forms/SearchInput'
import * as Layout from '#/components/Layout'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
import {account, useStorage} from '#/storage'
import type * as bsky from '#/types/bsky'
import {AutocompleteResults} from './components/AutocompleteResults'
@@ -141,7 +141,7 @@ export function SearchScreenShell({
const [headerHeight, setHeaderHeight] = useState(0)
const headerRef = useRef(null)
useLayoutEffect(() => {
if (isWeb) {
if (IS_WEB) {
if (!headerRef.current) return
const measurement = (headerRef.current as Element).getBoundingClientRect()
setHeaderHeight(measurement.height)
@@ -150,7 +150,7 @@ export function SearchScreenShell({
useFocusEffect(
useNonReactiveCallback(() => {
if (isWeb) {
if (IS_WEB) {
setSearchText(queryParam)
}
}),
@@ -173,7 +173,7 @@ export function SearchScreenShell({
setShowAutocomplete(false)
updateSearchHistory(item)
if (isWeb) {
if (IS_WEB) {
// @ts-expect-error route is not typesafe
navigation.push(route.name, {...route.params, q: item})
} else {
@@ -188,7 +188,7 @@ export function SearchScreenShell({
scrollToTopWeb()
textInput.current?.blur()
setShowAutocomplete(false)
if (isWeb) {
if (IS_WEB) {
// Empty params resets the URL to be /search rather than /search?q=
// Also clear the tab parameter
const {
@@ -211,7 +211,7 @@ export function SearchScreenShell({
}, [navigateToItem, searchText])
const onAutocompleteResultPress = useCallback(() => {
if (isWeb) {
if (IS_WEB) {
setShowAutocomplete(false)
} else {
textInput.current?.blur()
@@ -238,7 +238,7 @@ export function SearchScreenShell({
)
const onSoftReset = useCallback(() => {
if (isWeb) {
if (IS_WEB) {
// Empty params resets the URL to be /search rather than /search?q=
// Also clear the tab parameter when soft resetting
const {
@@ -265,7 +265,7 @@ export function SearchScreenShell({
)
const onSearchInputFocus = useCallback(() => {
if (isWeb) {
if (IS_WEB) {
// Prevent a jump on iPad by ensuring that
// the initial focused render has no result list.
requestAnimationFrame(() => {
@@ -282,7 +282,7 @@ export function SearchScreenShell({
// If a tab is specified, set the tab parameter
if (tab) {
if (isWeb) {
if (IS_WEB) {
navigation.setParams({...route.params, tab})
} else {
navigation.setParams({tab})
@@ -299,7 +299,7 @@ export function SearchScreenShell({
<View
ref={headerRef}
onLayout={evt => {
if (isWeb) setHeaderHeight(evt.nativeEvent.layout.height)
if (IS_WEB) setHeaderHeight(evt.nativeEvent.layout.height)
}}
style={[
a.relative,
@@ -581,7 +581,7 @@ function useQueryManager({
}
function scrollToTopWeb() {
if (isWeb) {
if (IS_WEB) {
window.scrollTo(0, 0)
}
}
@@ -4,12 +4,12 @@ import {type AppBskyActorDefs} from '@atproto/api'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {isNative} from '#/platform/detection'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {SearchLinkCard} from '#/view/shell/desktop/Search'
import {SearchProfileCard} from '#/screens/Search/components/SearchProfileCard'
import {atoms as a, native} from '#/alf'
import * as Layout from '#/components/Layout'
import {IS_NATIVE} from '#/env'
let AutocompleteResults = ({
isAutocompleteFetching,
@@ -45,7 +45,7 @@ let AutocompleteResults = ({
label={_(msg`Search for "${searchText}"`)}
onPress={native(onSubmit)}
to={
isNative
IS_NATIVE
? undefined
: `/search?q=${encodeURIComponent(searchText)}`
}
@@ -3,7 +3,6 @@ import {type AppBskyUnspeccedDefs} from '@atproto/api'
import {Trans} from '@lingui/macro'
import {logger} from '#/logger'
import {isWeb} from '#/platform/detection'
import {
DEFAULT_LIMIT as RECOMMENDATIONS_COUNT,
useTrendingTopics,
@@ -17,6 +16,7 @@ import {
TrendingTopicSkeleton,
} from '#/components/TrendingTopics'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
// Note: This module is not currently used and may be removed in the future.
@@ -37,7 +37,7 @@ function Inner() {
<View
style={[
a.flex_row,
isWeb
IS_WEB
? [a.px_lg, a.py_lg, a.pt_2xl, a.gap_md]
: [a.p_lg, a.pt_2xl, a.gap_md],
a.border_b,