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
+3 -3
View File
@@ -7,7 +7,6 @@ import {useCleanError} from '#/lib/hooks/useCleanError'
import {isAppPassword} from '#/lib/jwt'
import {getAge, getDateAgo} from '#/lib/strings/time'
import {logger} from '#/logger'
import {isIOS, isWeb} from '#/platform/detection'
import {
useBirthdateMutation,
useIsBirthdateUpdateAllowed,
@@ -26,6 +25,7 @@ import {DateField} from '#/components/forms/DateField'
import {SimpleInlineLinkText} from '#/components/Link'
import {Loader} from '#/components/Loader'
import {Span, Text} from '#/components/Typography'
import {IS_IOS, IS_WEB} from '#/env'
export function BirthDateSettingsDialog({
control,
@@ -154,7 +154,7 @@ function BirthdayInner({
return (
<View style={a.gap_lg} testID="birthDateSettingsDialog">
<View style={isIOS && [a.w_full, a.align_center]}>
<View style={IS_IOS && [a.w_full, a.align_center]}>
<DateField
testID="birthdayInput"
value={date}
@@ -191,7 +191,7 @@ function BirthdayInner({
<ErrorMessage message={errorMessage} style={[a.rounded_sm]} />
) : undefined}
<View style={isWeb && [a.flex_row, a.justify_end]}>
<View style={IS_WEB && [a.flex_row, a.justify_end]}>
<Button
label={hasChanged ? _(msg`Save birthdate`) : _(msg`Done`)}
size="large"
@@ -6,7 +6,6 @@ import {useLingui} from '@lingui/react'
import {wait} from '#/lib/async/wait'
import {isNetworkError, useCleanError} from '#/lib/hooks/useCleanError'
import {logger} from '#/logger'
import {isWeb} from '#/platform/detection'
import {atoms as a, useTheme, web} from '#/alf'
import {Admonition} from '#/components/Admonition'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
@@ -14,6 +13,7 @@ import * as Dialog from '#/components/Dialog'
import {PinLocation_Stroke2_Corner0_Rounded as LocationIcon} from '#/components/icons/PinLocation'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
import {type Geolocation, useRequestDeviceGeolocation} from '#/geolocation'
export type Props = {
@@ -138,7 +138,7 @@ function DeviceLocationRequestDialogInner({onLocationAcquired}: Props) {
disabled={isRequesting}
label={_(msg`Allow location access`)}
onPress={onPressConfirm}
size={isWeb ? 'small' : 'large'}
size={IS_WEB ? 'small' : 'large'}
color="primary">
<ButtonIcon icon={isRequesting ? Loader : LocationIcon} />
<ButtonText>
@@ -147,11 +147,11 @@ function DeviceLocationRequestDialogInner({onLocationAcquired}: Props) {
</Button>
)}
{!isWeb && (
{!IS_WEB && (
<Button
label={_(msg`Cancel`)}
onPress={() => close()}
size={isWeb ? 'small' : 'large'}
size={IS_WEB ? 'small' : 'large'}
color="secondary">
<ButtonText>
<Trans>Cancel</Trans>
+3 -3
View File
@@ -13,7 +13,6 @@ import {useLingui} from '@lingui/react'
import {logEvent} from '#/lib/statsig/statsig'
import {cleanError} from '#/lib/strings/errors'
import {isWeb} from '#/platform/detection'
import {
type Gif,
tenorUrlToBskyGifUrl,
@@ -31,6 +30,7 @@ import {useThrottledValue} from '#/components/hooks/useThrottledValue'
import {ArrowLeft_Stroke2_Corner0_Rounded as Arrow} from '#/components/icons/Arrow'
import {MagnifyingGlass_Stroke2_Corner0_Rounded as Search} from '#/components/icons/MagnifyingGlass'
import {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
import {IS_WEB} from '#/env'
export function GifSelectDialog({
controlRef,
@@ -149,7 +149,7 @@ function GifList({
a.pb_sm,
t.atoms.bg,
]}>
{!gtMobile && isWeb && (
{!gtMobile && IS_WEB && (
<Button
size="small"
variant="ghost"
@@ -161,7 +161,7 @@ function GifList({
</Button>
)}
<TextField.Root style={[!gtMobile && isWeb && a.flex_1]}>
<TextField.Root style={[!gtMobile && IS_WEB && a.flex_1]}>
<TextField.Icon icon={Search} />
<TextField.Input
label={_(msg`Search GIFs`)}
@@ -4,19 +4,19 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useOpenLink} from '#/lib/hooks/useOpenLink'
import {isWeb} from '#/platform/detection'
import {useSetInAppBrowser} from '#/state/preferences/in-app-browser'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {SquareArrowTopRight_Stroke2_Corner0_Rounded as External} from '#/components/icons/SquareArrowTopRight'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
import {useGlobalDialogsControlContext} from './Context'
export function InAppBrowserConsentDialog() {
const {inAppBrowserConsentControl} = useGlobalDialogsControlContext()
if (isWeb) return null
if (IS_WEB) return null
return (
<Dialog.Outer
+2 -2
View File
@@ -5,7 +5,6 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {
usePreferencesQuery,
useRemoveMutedWordMutation,
@@ -32,6 +31,7 @@ import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
import {Loader} from '#/components/Loader'
import * as Prompt from '#/components/Prompt'
import {Text} from '#/components/Typography'
import {IS_NATIVE} from '#/env'
const ONE_DAY = 24 * 60 * 60 * 1000
@@ -406,7 +406,7 @@ function MutedWordsInner() {
)}
</View>
{isNative && <View style={{height: 20}} />}
{IS_NATIVE && <View style={{height: 20}} />}
</View>
<Dialog.Close />
@@ -12,7 +12,6 @@ import {useQueryClient} from '@tanstack/react-query'
import {useHaptics} from '#/lib/haptics'
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {logger} from '#/logger'
import {isIOS} from '#/platform/detection'
import {STALE} from '#/state/queries'
import {useMyListsQuery} from '#/state/queries/my-lists'
import {useGetPost} from '#/state/queries/post'
@@ -52,6 +51,7 @@ import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/ico
import {CloseQuote_Stroke2_Corner1_Rounded as QuoteIcon} from '#/components/icons/Quote'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography'
import {IS_IOS} from '#/env'
export type PostInteractionSettingsFormProps = {
canSave?: boolean
@@ -531,7 +531,7 @@ export function PostInteractionSettingsForm({
hitSlop={0}
onPress={() => {
playHaptic('Light')
if (isIOS && !showLists) {
if (IS_IOS && !showLists) {
LayoutAnimation.configureNext({
...LayoutAnimation.Presets.linear,
duration: 175,
@@ -13,7 +13,6 @@ import {useLingui} from '@lingui/react'
import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {sanitizeHandle} from '#/lib/strings/handles'
import {isWeb} from '#/platform/detection'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
import {useListConvosQuery} from '#/state/queries/messages/list-conversations'
@@ -29,6 +28,7 @@ import {MagnifyingGlass_Stroke2_Corner0_Rounded as Search} from '#/components/ic
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
import * as ProfileCard from '#/components/ProfileCard'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
import type * as bsky from '#/types/bsky'
export type ProfileItem = {
@@ -254,7 +254,7 @@ export function SearchablePeopleList({
)
useLayoutEffect(() => {
if (isWeb) {
if (IS_WEB) {
setImmediate(() => {
inputRef?.current?.focus()
})
@@ -290,12 +290,12 @@ export function SearchablePeopleList({
]}>
{title}
</Text>
{isWeb ? (
{IS_WEB ? (
<Button
label={_(msg`Close`)}
size="small"
shape="round"
variant={isWeb ? 'ghost' : 'solid'}
variant={IS_WEB ? 'ghost' : 'solid'}
color="secondary"
style={[
a.absolute,
+3 -3
View File
@@ -3,7 +3,6 @@ import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {isNative} from '#/platform/detection'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useCloseAllActiveElements} from '#/state/util'
import {Logo} from '#/view/icons/Logo'
@@ -13,6 +12,7 @@ import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
import {Text} from '#/components/Typography'
import {IS_NATIVE} from '#/env'
export function SigninDialog() {
const {signinDialogControl: control} = useGlobalDialogsControlContext()
@@ -45,7 +45,7 @@ function SigninDialogInner({}: {control: Dialog.DialogOuterProps['control']}) {
<Dialog.ScrollableInner
label={_(msg`Sign in to Bluesky or create a new account`)}
style={[gtMobile ? {width: 'auto', maxWidth: 420} : a.w_full]}>
<View style={[!isNative && a.p_2xl]}>
<View style={[!IS_NATIVE && a.p_2xl]}>
<View
style={[
a.flex_row,
@@ -101,7 +101,7 @@ function SigninDialogInner({}: {control: Dialog.DialogOuterProps['control']}) {
</Button>
</View>
{isNative && <View style={{height: 10}} />}
{IS_NATIVE && <View style={{height: 10}} />}
</View>
<Dialog.Close />
+4 -4
View File
@@ -12,7 +12,6 @@ import {useQueryClient} from '@tanstack/react-query'
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
import {type NavigationProp} from '#/lib/routes/types'
import {logger} from '#/logger'
import {isWeb} from '#/platform/detection'
import {
invalidateActorStarterPacksWithMembershipQuery,
useActorStarterPacksWithMembershipsQuery,
@@ -32,6 +31,7 @@ import {StarterPack} from '#/components/icons/StarterPack'
import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
import * as bsky from '#/types/bsky'
type StarterPackWithMembership =
@@ -91,7 +91,7 @@ function Empty({onStartWizard}: {onStartWizard: () => void}) {
const t = useTheme()
return (
<View style={[a.gap_2xl, {paddingTop: isWeb ? 100 : 64}]}>
<View style={[a.gap_2xl, {paddingTop: IS_WEB ? 100 : 64}]}>
<View style={[a.gap_xs, a.align_center]}>
<StarterPack
width={48}
@@ -169,7 +169,7 @@ function StarterPackList({
<View
style={[
{justifyContent: 'space-between', flexDirection: 'row'},
isWeb ? a.mb_2xl : a.my_lg,
IS_WEB ? a.mb_2xl : a.my_lg,
a.align_center,
]}>
<Text style={[a.text_lg, a.font_semi_bold]}>
@@ -232,7 +232,7 @@ function StarterPackList({
onEndReachedThreshold={0.1}
ListHeaderComponent={listHeader}
ListEmptyComponent={<Empty onStartWizard={onStartWizard} />}
style={isWeb ? [a.px_md, {minHeight: 500}] : [a.px_2xl, a.pt_lg]}
style={IS_WEB ? [a.px_md, {minHeight: 500}] : [a.px_2xl, a.pt_lg]}
/>
)
}
@@ -9,7 +9,6 @@ import {isOverMaxGraphemeCount} from '#/lib/strings/helpers'
import {richTextToString} from '#/lib/strings/rich-text-helpers'
import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip'
import {logger} from '#/logger'
import {isWeb} from '#/platform/detection'
import {type ImageMeta} from '#/state/gallery'
import {
useListCreateMutation,
@@ -26,6 +25,7 @@ import * as TextField from '#/components/forms/TextField'
import {Loader} from '#/components/Loader'
import * as Prompt from '#/components/Prompt'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
const DISPLAY_NAME_MAX_GRAPHEMES = 64
const DESCRIPTION_MAX_GRAPHEMES = 300
@@ -48,7 +48,7 @@ export function CreateOrEditListDialog({
// 'You might lose unsaved changes' warning
useEffect(() => {
if (isWeb && dirty) {
if (IS_WEB && dirty) {
const abortController = new AbortController()
const {signal} = abortController
window.addEventListener('beforeunload', evt => evt.preventDefault(), {
@@ -4,13 +4,13 @@ import {Image} from 'expo-image'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {isWeb} from '#/platform/detection'
import {atoms as a, useTheme, web} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {useNuxDialogContext} from '#/components/dialogs/nuxs'
import {Sparkle_Stroke2_Corner0_Rounded as SparkleIcon} from '#/components/icons/Sparkle'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
export function ActivitySubscriptionsNUX() {
const t = useTheme()
@@ -44,8 +44,8 @@ export function ActivitySubscriptionsNUX() {
a.overflow_hidden,
t.atoms.bg_contrast_25,
{
gap: isWeb ? 16 : 24,
paddingTop: isWeb ? 24 : 48,
gap: IS_WEB ? 16 : 24,
paddingTop: IS_WEB ? 24 : 48,
borderTopLeftRadius: a.rounded_md.borderRadius,
borderTopRightRadius: a.rounded_md.borderRadius,
},
@@ -120,7 +120,7 @@ export function ActivitySubscriptionsNUX() {
style={[
a.align_center,
a.px_xl,
isWeb ? [a.pt_xl, a.gap_xl, a.pb_sm] : [a.pt_3xl, a.gap_3xl],
IS_WEB ? [a.pt_xl, a.gap_xl, a.pb_sm] : [a.pt_3xl, a.gap_3xl],
]}>
<View style={[a.gap_md, a.align_center]}>
<Text
@@ -130,7 +130,7 @@ export function ActivitySubscriptionsNUX() {
a.font_bold,
a.text_center,
{
fontSize: isWeb ? 28 : 32,
fontSize: IS_WEB ? 28 : 32,
maxWidth: 300,
},
]}>
@@ -153,7 +153,7 @@ export function ActivitySubscriptionsNUX() {
</Text>
</View>
{!isWeb && (
{!IS_WEB && (
<Button
label={_(msg`Close`)}
size="large"
@@ -5,7 +5,6 @@ import {LinearGradient} from 'expo-linear-gradient'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {isWeb} from '#/platform/detection'
import {atoms as a, useTheme, web} from '#/alf'
import {transparentifyColor} from '#/alf/util/colorGeneration'
import {Button, ButtonText} from '#/components/Button'
@@ -13,6 +12,7 @@ import * as Dialog from '#/components/Dialog'
import {useNuxDialogContext} from '#/components/dialogs/nuxs'
import {Sparkle_Stroke2_Corner0_Rounded as SparkleIcon} from '#/components/icons/Sparkle'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
export function BookmarksAnnouncement() {
const t = useTheme()
@@ -49,7 +49,7 @@ export function BookmarksAnnouncement() {
a.overflow_hidden,
{
gap: 16,
paddingTop: isWeb ? 24 : 40,
paddingTop: IS_WEB ? 24 : 40,
borderTopLeftRadius: a.rounded_md.borderRadius,
borderTopRightRadius: a.rounded_md.borderRadius,
},
@@ -90,7 +90,7 @@ export function BookmarksAnnouncement() {
borderRadius: 24,
aspectRatio: 333 / 104,
},
isWeb
IS_WEB
? [
{
boxShadow: `0px 10px 15px -3px ${transparentifyColor(t.palette.black, 0.2)}`,
@@ -136,7 +136,7 @@ export function BookmarksAnnouncement() {
a.font_bold,
a.text_center,
{
fontSize: isWeb ? 28 : 32,
fontSize: IS_WEB ? 28 : 32,
maxWidth: 300,
},
]}>
@@ -158,7 +158,7 @@ export function BookmarksAnnouncement() {
</Text>
</View>
{!isWeb && (
{!IS_WEB && (
<Button
label={_(msg`Close`)}
size="large"
@@ -6,7 +6,6 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {isNative, isWeb} from '#/platform/detection'
import {atoms as a, useTheme, web} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import {isFindContactsFeatureEnabled} from '#/components/contacts/country-allowlist'
@@ -17,13 +16,14 @@ import {
isExistingUserAsOf,
} from '#/components/dialogs/nuxs/utils'
import {Text} from '#/components/Typography'
import {IS_NATIVE, IS_WEB} from '#/env'
import {IS_E2E} from '#/env'
import {navigate} from '#/Navigation'
export const enabled = createIsEnabledCheck(props => {
return (
!IS_E2E &&
isNative &&
IS_NATIVE &&
isExistingUserAsOf(
'2025-12-16T00:00:00.000Z',
props.currentProfile.createdAt,
@@ -89,7 +89,7 @@ export function FindContactsAnnouncement() {
a.font_bold,
a.text_center,
{
fontSize: isWeb ? 28 : 32,
fontSize: IS_WEB ? 28 : 32,
maxWidth: 300,
},
]}>
@@ -6,7 +6,6 @@ import {useLingui} from '@lingui/react'
import {urls} from '#/lib/constants'
import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
@@ -15,6 +14,7 @@ import {Sparkle_Stroke2_Corner0_Rounded as SparkleIcon} from '#/components/icons
import {VerifierCheck} from '#/components/icons/VerifierCheck'
import {Link} from '#/components/Link'
import {Span, Text} from '#/components/Typography'
import {IS_NATIVE} from '#/env'
export function InitialVerificationAnnouncement() {
const t = useTheme()
@@ -173,7 +173,7 @@ export function InitialVerificationAnnouncement() {
<Trans>Read blog post</Trans>
</ButtonText>
</Link>
{isNative && (
{IS_NATIVE && (
<Button
label={_(msg`Close`)}
size="small"
@@ -5,7 +5,6 @@ import {LinearGradient} from 'expo-linear-gradient'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {isWeb} from '#/platform/detection'
import {atoms as a, select, useTheme, utils, web} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
@@ -16,6 +15,7 @@ import {
} from '#/components/dialogs/nuxs/utils'
import {Beaker_Stroke2_Corner2_Rounded as BeakerIcon} from '#/components/icons/Beaker'
import {Text} from '#/components/Typography'
import {IS_WEB} from '#/env'
import {IS_E2E} from '#/env'
export const enabled = createIsEnabledCheck(props => {
@@ -72,7 +72,7 @@ export function LiveNowBetaDialog() {
a.overflow_hidden,
{
gap: 16,
paddingTop: isWeb ? 24 : 40,
paddingTop: IS_WEB ? 24 : 40,
borderTopLeftRadius: a.rounded_md.borderRadius,
borderTopRightRadius: a.rounded_md.borderRadius,
},
@@ -116,7 +116,7 @@ export function LiveNowBetaDialog() {
borderRadius: 24,
aspectRatio: 652 / 211,
},
isWeb
IS_WEB
? [
{
boxShadow: `0px 10px 15px -3px ${shadowColor}`,
@@ -163,7 +163,7 @@ export function LiveNowBetaDialog() {
a.font_bold,
a.text_center,
{
fontSize: isWeb ? 28 : 32,
fontSize: IS_WEB ? 28 : 32,
maxWidth: 360,
},
]}>
@@ -186,7 +186,7 @@ export function LiveNowBetaDialog() {
</Text>
</View>
{!isWeb && (
{!IS_WEB && (
<Button
label={_(msg`Close`)}
size="large"