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
@@ -13,7 +13,6 @@ import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerificati
import {type MessagesTabNavigatorParams} from '#/lib/routes/types'
import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {listenSoftReset} from '#/state/events'
import {MESSAGE_SCREEN_POLL_INTERVAL} from '#/state/messages/convo/const'
import {useMessagesEventBus} from '#/state/messages/events'
@@ -38,6 +37,7 @@ import * as Layout from '#/components/Layout'
import {Link} from '#/components/Link'
import {ListFooter} from '#/components/Lists'
import {Text} from '#/components/Typography'
import {IS_NATIVE} from '#/env'
import {ChatListItem} from './components/ChatListItem'
import {InboxPreview} from './components/InboxPreview'
@@ -222,7 +222,7 @@ export function MessagesScreenInner({navigation, route}: Props) {
const onSoftReset = useCallback(async () => {
scrollElRef.current?.scrollToOffset({
animated: isNative,
animated: IS_NATIVE,
offset: 0,
})
try {
@@ -348,7 +348,7 @@ export function MessagesScreenInner({navigation, route}: Props) {
hasNextPage={hasNextPage}
/>
}
onEndReachedThreshold={isNative ? 1.5 : 0}
onEndReachedThreshold={IS_NATIVE ? 1.5 : 0}
initialNumToRender={initialNumToRender}
windowSize={11}
desktopFixedHeight
+2 -2
View File
@@ -21,7 +21,6 @@ import {
type CommonNavigatorParams,
type NavigationProp,
} from '#/lib/routes/types'
import {isWeb} from '#/platform/detection'
import {type Shadow, useMaybeProfileShadow} from '#/state/cache/profile-shadow'
import {useEmail} from '#/state/email-verification'
import {ConvoProvider, isConvoActive, useConvo} from '#/state/messages/convo'
@@ -43,6 +42,7 @@ import {MessagesListHeader} from '#/components/dms/MessagesListHeader'
import {Error} from '#/components/Error'
import * as Layout from '#/components/Layout'
import {Loader} from '#/components/Loader'
import {IS_WEB} from '#/env'
type Props = NativeStackScreenProps<
CommonNavigatorParams,
@@ -74,7 +74,7 @@ export function MessagesConversationScreenInner({route}: Props) {
useCallback(() => {
setCurrentConvoId(convoId)
if (isWeb && !gtMobile) {
if (IS_WEB && !gtMobile) {
setMinimalShellMode(true)
} else {
setMinimalShellMode(false)
+2 -2
View File
@@ -21,7 +21,6 @@ import {
} from '#/lib/routes/types'
import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {MESSAGE_SCREEN_POLL_INTERVAL} from '#/state/messages/convo/const'
import {useMessagesEventBus} from '#/state/messages/events'
import {useLeftConvos} from '#/state/queries/messages/leave-conversation'
@@ -44,6 +43,7 @@ import {Message_Stroke2_Corner0_Rounded as MessageIcon} from '#/components/icons
import * as Layout from '#/components/Layout'
import {ListFooter} from '#/components/Lists'
import {Text} from '#/components/Typography'
import {IS_NATIVE} from '#/env'
import {RequestListItem} from './components/RequestListItem'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'MessagesInbox'>
@@ -288,7 +288,7 @@ function RequestList({
hasNextPage={hasNextPage}
/>
}
onEndReachedThreshold={isNative ? 1.5 : 0}
onEndReachedThreshold={IS_NATIVE ? 1.5 : 0}
initialNumToRender={initialNumToRender}
windowSize={11}
desktopFixedHeight
+2 -2
View File
@@ -5,7 +5,6 @@ import {useLingui} from '@lingui/react'
import {type NativeStackScreenProps} from '@react-navigation/native-stack'
import {type CommonNavigatorParams} from '#/lib/routes/types'
import {isNative} from '#/platform/detection'
import {useUpdateActorDeclaration} from '#/state/queries/messages/actor-declaration'
import {useProfileQuery} from '#/state/queries/profile'
import {useSession} from '#/state/session'
@@ -16,6 +15,7 @@ import {Divider} from '#/components/Divider'
import * as Toggle from '#/components/forms/Toggle'
import * as Layout from '#/components/Layout'
import {Text} from '#/components/Typography'
import {IS_NATIVE} from '#/env'
import {useBackgroundNotificationPreferences} from '../../../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider'
type AllowIncoming = 'all' | 'none' | 'following'
@@ -118,7 +118,7 @@ export function MessagesSettingsScreenInner({}: Props) {
you choose.
</Trans>
</Admonition>
{isNative && (
{IS_NATIVE && (
<>
<Divider style={a.my_md} />
<Text style={[a.text_lg, a.font_semi_bold]}>
@@ -20,7 +20,6 @@ import {
toBskyAppUrl,
toShortUrl,
} from '#/lib/strings/url-helpers'
import {isNative} from '#/platform/detection'
import {useProfileShadow} from '#/state/cache/profile-shadow'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {
@@ -46,6 +45,7 @@ import {createPortalGroup} from '#/components/Portal'
import {Text} from '#/components/Typography'
import {useSimpleVerificationState} from '#/components/verification'
import {VerificationCheck} from '#/components/verification/VerificationCheck'
import {IS_NATIVE} from '#/env'
import type * as bsky from '#/types/bsky'
export const ChatListItemPortal = createPortalGroup()
@@ -366,7 +366,7 @@ function ChatListItemReady({
)
}
accessibilityActions={
isNative
IS_NATIVE
? [
{
name: 'magicTap',
@@ -380,7 +380,7 @@ function ChatListItemReady({
: undefined
}
onPress={onPress}
onLongPress={isNative ? onLongPress : undefined}
onLongPress={IS_NATIVE ? onLongPress : undefined}
onAccessibilityAction={onLongPress}>
{({hovered, pressed, focused}) => (
<View
@@ -519,7 +519,7 @@ function ChatListItemReady({
control={menuControl}
currentScreen="list"
showMarkAsRead={convo.unreadCount > 0}
hideTrigger={isNative}
hideTrigger={IS_NATIVE}
blockInfo={blockInfo}
style={[
a.absolute,
@@ -18,7 +18,6 @@ import {countGraphemes} from 'unicode-segmenter/grapheme'
import {HITSLOP_10, MAX_DM_GRAPHEME_LENGTH} from '#/lib/constants'
import {useHaptics} from '#/lib/haptics'
import {isIOS, isWeb} from '#/platform/detection'
import {useEmail} from '#/state/email-verification'
import {
useMessageDraft,
@@ -29,6 +28,7 @@ import * as Toast from '#/view/com/util/Toast'
import {android, atoms as a, useTheme} from '#/alf'
import {useSharedInputStyles} from '#/components/forms/TextField'
import {PaperPlane_Stroke2_Corner0_Rounded as PaperPlane} from '#/components/icons/PaperPlane'
import {IS_IOS, IS_WEB} from '#/env'
import {useExtractEmbedFromFacets} from './MessageInputEmbed'
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput)
@@ -84,10 +84,10 @@ export function MessageInput({
playHaptic()
setEmbed(undefined)
setMessage('')
if (isIOS) {
if (IS_IOS) {
setShouldEnforceClear(true)
}
if (isWeb) {
if (IS_WEB) {
// Pressing the send button causes the text input to lose focus, so we need to
// re-focus it after sending
setTimeout(() => {
@@ -160,7 +160,7 @@ export function MessageInput({
// next change and double make sure the input is cleared. It should *always* send an onChange event after
// clearing via setMessage('') that happens in onSubmit()
// -sfn
if (isIOS && shouldEnforceClear) {
if (IS_IOS && shouldEnforceClear) {
setShouldEnforceClear(false)
setMessage('')
return
@@ -175,7 +175,7 @@ export function MessageInput({
a.px_sm,
t.atoms.text,
android({paddingTop: 0}),
{paddingBottom: isIOS ? 5 : 0},
{paddingBottom: IS_IOS ? 5 : 0},
animatedStyle,
]}
keyboardAppearance={t.scheme}
@@ -24,8 +24,6 @@ import {
isBskyPostUrl,
} from '#/lib/strings/url-helpers'
import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {isWeb} from '#/platform/detection'
import {
type ActiveConvoStates,
isConvoActive,
@@ -52,6 +50,8 @@ import {MessageItem} from '#/components/dms/MessageItem'
import {NewMessagesPill} from '#/components/dms/NewMessagesPill'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography'
import {IS_NATIVE} from '#/env'
import {IS_WEB} from '#/env'
import {ChatStatusInfo} from './ChatStatusInfo'
import {MessageInputEmbed, useMessageEmbed} from './MessageInputEmbed'
@@ -159,7 +159,7 @@ export function MessagesList({
(_: number, height: number) => {
// Because web does not have `maintainVisibleContentPosition` support, we will need to manually scroll to the
// previous off whenever we add new content to the previous offset whenever we add new content to the list.
if (isWeb && isAtTop.get() && hasScrolled) {
if (IS_WEB && isAtTop.get() && hasScrolled) {
flatListRef.current?.scrollToOffset({
offset: height - prevContentHeight.current,
animated: false,
@@ -390,7 +390,7 @@ export function MessagesList({
(e: LayoutChangeEvent) => {
layoutHeight.set(e.nativeEvent.layout.height)
if (isWeb || !keyboardIsOpening.get()) {
if (IS_WEB || !keyboardIsOpening.get()) {
flatListRef.current?.scrollToEnd({
animated: !layoutScrollWithoutAnimation.get(),
})
@@ -429,8 +429,8 @@ export function MessagesList({
disableVirtualization={true}
style={animatedListStyle}
// The extra two items account for the header and the footer components
initialNumToRender={isNative ? 32 : 62}
maxToRenderPerBatch={isWeb ? 32 : 62}
initialNumToRender={IS_NATIVE ? 32 : 62}
maxToRenderPerBatch={IS_WEB ? 32 : 62}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
maintainVisibleContentPosition={{
@@ -468,7 +468,7 @@ export function MessagesList({
)}
</Animated.View>
{isWeb && (
{IS_WEB && (
<EmojiPicker
pinToTop
state={emojiPickerState}