Move /platform/detection vars into /env (#9707)
* Add platform vars to env * Replace /platform/detection with /env
This commit is contained in:
@@ -11,7 +11,6 @@ import {Statsig} from 'statsig-react-native-expo'
|
||||
|
||||
import {STATUS_PAGE_URL} from '#/lib/constants'
|
||||
import {type CommonNavigatorParams} from '#/lib/routes/types'
|
||||
import {isAndroid, isIOS, isNative} from '#/platform/detection'
|
||||
import * as Toast from '#/view/com/util/Toast'
|
||||
import * as SettingsList from '#/screens/Settings/components/SettingsList'
|
||||
import {Atom_Stroke2_Corner0_Rounded as AtomIcon} from '#/components/icons/Atom'
|
||||
@@ -22,6 +21,7 @@ import {Newspaper_Stroke2_Corner2_Rounded as NewspaperIcon} from '#/components/i
|
||||
import {Wrench_Stroke2_Corner2_Rounded as WrenchIcon} from '#/components/icons/Wrench'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import {IS_ANDROID, IS_IOS, IS_NATIVE} from '#/env'
|
||||
import * as env from '#/env'
|
||||
import {useDemoMode} from '#/storage/hooks/demo-mode'
|
||||
import {useDevMode} from '#/storage/hooks/dev-mode'
|
||||
@@ -44,7 +44,7 @@ export function AboutSettingsScreen({}: Props) {
|
||||
return spaceDiff * -1
|
||||
},
|
||||
onSuccess: sizeDiffBytes => {
|
||||
if (isAndroid) {
|
||||
if (IS_ANDROID) {
|
||||
Toast.show(
|
||||
_(
|
||||
msg({
|
||||
@@ -110,7 +110,7 @@ export function AboutSettingsScreen({}: Props) {
|
||||
<Trans>System log</Trans>
|
||||
</SettingsList.ItemText>
|
||||
</SettingsList.LinkItem>
|
||||
{isNative && (
|
||||
{IS_NATIVE && (
|
||||
<SettingsList.PressableItem
|
||||
onPress={() => onClearImageCache()}
|
||||
label={_(msg`Clear image cache`)}
|
||||
@@ -159,7 +159,7 @@ export function AboutSettingsScreen({}: Props) {
|
||||
{devModeEnabled && (
|
||||
<>
|
||||
<OTAInfo />
|
||||
{isIOS && (
|
||||
{IS_IOS && (
|
||||
<SettingsList.PressableItem
|
||||
onPress={() => {
|
||||
const newDemoModeEnabled = !demoModeEnabled
|
||||
|
||||
@@ -3,7 +3,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 {
|
||||
useHapticsDisabled,
|
||||
useRequireAltTextEnabled,
|
||||
@@ -20,6 +19,7 @@ import * as Toggle from '#/components/forms/Toggle'
|
||||
import {Accessibility_Stroke2_Corner2_Rounded as AccessibilityIcon} from '#/components/icons/Accessibility'
|
||||
import {Haptic_Stroke2_Corner2_Rounded as HapticIcon} from '#/components/icons/Haptic'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
|
||||
type Props = NativeStackScreenProps<
|
||||
CommonNavigatorParams,
|
||||
@@ -76,7 +76,7 @@ export function AccessibilitySettingsScreen({}: Props) {
|
||||
<Toggle.Platform />
|
||||
</Toggle.Item>
|
||||
</SettingsList.Group>
|
||||
{isNative && (
|
||||
{IS_NATIVE && (
|
||||
<>
|
||||
<SettingsList.Divider />
|
||||
<SettingsList.Group contentContainerStyle={[a.gap_sm]}>
|
||||
|
||||
@@ -8,7 +8,6 @@ import {type NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||
import {PressableScale} from '#/lib/custom-animations/PressableScale'
|
||||
import {type CommonNavigatorParams} from '#/lib/routes/types'
|
||||
import {useGate} from '#/lib/statsig/statsig'
|
||||
import {isAndroid} from '#/platform/detection'
|
||||
import {AppIconImage} from '#/screens/Settings/AppIconSettings/AppIconImage'
|
||||
import {type AppIconSet} from '#/screens/Settings/AppIconSettings/types'
|
||||
import {useAppIconSets} from '#/screens/Settings/AppIconSettings/useAppIconSets'
|
||||
@@ -16,6 +15,7 @@ import {atoms as a, useTheme} from '#/alf'
|
||||
import * as Toggle from '#/components/forms/Toggle'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {IS_ANDROID} from '#/env'
|
||||
import {IS_INTERNAL} from '#/env'
|
||||
|
||||
type Props = NativeStackScreenProps<CommonNavigatorParams, 'AppIconSettings'>
|
||||
@@ -29,7 +29,7 @@ export function AppIconSettingsScreen({}: Props) {
|
||||
)
|
||||
|
||||
const onSetAppIcon = (icon: DynamicAppIcon.IconName) => {
|
||||
if (isAndroid) {
|
||||
if (IS_ANDROID) {
|
||||
const next =
|
||||
sets.defaults.find(i => i.id === icon) ??
|
||||
sets.core.find(i => i.id === icon)
|
||||
@@ -221,7 +221,7 @@ function AppIcon({icon, size = 50}: {icon: AppIconSet; size: number}) {
|
||||
accessibilityHint={_(msg`Changes app icon`)}
|
||||
targetScale={0.95}
|
||||
onPress={() => {
|
||||
if (isAndroid) {
|
||||
if (IS_ANDROID) {
|
||||
Alert.alert(
|
||||
_(msg`Change app icon to "${icon.name}"`),
|
||||
_(msg`The app will be restarted`),
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
type CommonNavigatorParams,
|
||||
type NativeStackScreenProps,
|
||||
} from '#/lib/routes/types'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {useSetThemePrefs, useThemePrefs} from '#/state/shell'
|
||||
import {SettingsListItem as AppIconSettingsListItem} from '#/screens/Settings/AppIconSettings/SettingsListItem'
|
||||
import {type Alf, atoms as a, native, useAlf, useTheme} from '#/alf'
|
||||
@@ -24,6 +23,7 @@ import {TextSize_Stroke2_Corner0_Rounded as TextSize} from '#/components/icons/T
|
||||
import {TitleCase_Stroke2_Corner0_Rounded as Aa} from '#/components/icons/TitleCase'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {IS_INTERNAL} from '#/env'
|
||||
import * as SettingsList from './components/SettingsList'
|
||||
|
||||
@@ -165,7 +165,7 @@ export function AppearanceSettingsScreen({}: Props) {
|
||||
onChange={onChangeFontScale}
|
||||
/>
|
||||
|
||||
{isNative && IS_INTERNAL && (
|
||||
{IS_NATIVE && IS_INTERNAL && (
|
||||
<>
|
||||
<SettingsList.Divider />
|
||||
<AppIconSettingsListItem />
|
||||
|
||||
@@ -4,7 +4,6 @@ import {type NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||
|
||||
import {type CommonNavigatorParams} from '#/lib/routes/types'
|
||||
import {logEvent} from '#/lib/statsig/statsig'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {useAutoplayDisabled, useSetAutoplayDisabled} from '#/state/preferences'
|
||||
import {
|
||||
useInAppBrowser,
|
||||
@@ -26,6 +25,7 @@ import {Play_Stroke2_Corner2_Rounded as PlayIcon} from '#/components/icons/Play'
|
||||
import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending'
|
||||
import {Window_Stroke2_Corner2_Rounded as WindowIcon} from '#/components/icons/Window'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {LiveEventFeedsSettingsToggle} from '#/features/liveEvents/components/LiveEventFeedsSettingsToggle'
|
||||
|
||||
type Props = NativeStackScreenProps<
|
||||
@@ -97,7 +97,7 @@ export function ContentAndMediaSettingsScreen({}: Props) {
|
||||
</SettingsList.ItemText>
|
||||
</SettingsList.LinkItem>
|
||||
<SettingsList.Divider />
|
||||
{isNative && (
|
||||
{IS_NATIVE && (
|
||||
<Toggle.Item
|
||||
name="use_in_app_browser"
|
||||
label={_(msg`Use in-app browser to open links`)}
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
} from '#/lib/routes/types'
|
||||
import {cleanError, isNetworkError} from '#/lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {
|
||||
updateProfileShadow,
|
||||
useProfileShadow,
|
||||
@@ -48,6 +47,7 @@ import {Loader} from '#/components/Loader'
|
||||
import * as ProfileCard from '#/components/ProfileCard'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import type * as bsky from '#/types/bsky'
|
||||
import {bulkWriteFollows} from '../Onboarding/util'
|
||||
|
||||
@@ -78,7 +78,7 @@ export function FindContactsSettingsScreen({}: Props) {
|
||||
</Layout.Header.Content>
|
||||
<Layout.Header.Slot />
|
||||
</Layout.Header.Outer>
|
||||
{isNative ? (
|
||||
{IS_NATIVE ? (
|
||||
data ? (
|
||||
!data.syncStatus ? (
|
||||
<Intro />
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
type AllNavigatorParams,
|
||||
type NativeStackScreenProps,
|
||||
} from '#/lib/routes/types'
|
||||
import {isAndroid, isIOS, isWeb} from '#/platform/detection'
|
||||
import {useNotificationSettingsQuery} from '#/state/queries/notifications/settings'
|
||||
import {atoms as a} from '#/alf'
|
||||
import {Admonition} from '#/components/Admonition'
|
||||
@@ -31,6 +30,7 @@ import {
|
||||
} from '#/components/icons/Repost'
|
||||
import {Shapes_Stroke2_Corner0_Rounded as ShapesIcon} from '#/components/icons/Shapes'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {IS_ANDROID, IS_IOS, IS_WEB} from '#/env'
|
||||
import * as SettingsList from '../components/SettingsList'
|
||||
import {ItemTextWithSubtitle} from './components/ItemTextWithSubtitle'
|
||||
|
||||
@@ -45,7 +45,7 @@ export function NotificationSettingsScreen({}: Props) {
|
||||
const {data: permissions, refetch} = useQuery({
|
||||
queryKey: RQKEY,
|
||||
queryFn: async () => {
|
||||
if (isWeb) return null
|
||||
if (IS_WEB) return null
|
||||
return await Notification.getPermissionsAsync()
|
||||
},
|
||||
})
|
||||
@@ -58,12 +58,12 @@ export function NotificationSettingsScreen({}: Props) {
|
||||
}, [appState, refetch])
|
||||
|
||||
const onRequestPermissions = async () => {
|
||||
if (isWeb) return
|
||||
if (IS_WEB) return
|
||||
if (permissions?.canAskAgain) {
|
||||
const response = await Notification.requestPermissionsAsync()
|
||||
queryClient.setQueryData(RQKEY, response)
|
||||
} else {
|
||||
if (isAndroid) {
|
||||
if (IS_ANDROID) {
|
||||
try {
|
||||
await Linking.sendIntent(
|
||||
'android.settings.APP_NOTIFICATION_SETTINGS',
|
||||
@@ -77,7 +77,7 @@ export function NotificationSettingsScreen({}: Props) {
|
||||
} catch {
|
||||
Linking.openSettings()
|
||||
}
|
||||
} else if (isIOS) {
|
||||
} else if (IS_IOS) {
|
||||
Linking.openSettings()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
import {useGate} from '#/lib/statsig/statsig'
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||
import {isIOS, isNative} from '#/platform/detection'
|
||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||
import * as persisted from '#/state/persisted'
|
||||
import {clearStorage} from '#/state/persisted'
|
||||
@@ -71,6 +70,7 @@ import {
|
||||
shouldShowVerificationCheckButton,
|
||||
VerificationCheckButton,
|
||||
} from '#/components/verification/VerificationCheckButton'
|
||||
import {IS_IOS, IS_NATIVE} from '#/env'
|
||||
import {IS_INTERNAL} from '#/env'
|
||||
import {device, useStorage} from '#/storage'
|
||||
import {useActivitySubscriptionsNudged} from '#/storage/hooks/activity-subscriptions-nudged'
|
||||
@@ -213,7 +213,7 @@ export function SettingsScreen({}: Props) {
|
||||
<Trans>Content and media</Trans>
|
||||
</SettingsList.ItemText>
|
||||
</SettingsList.LinkItem>
|
||||
{isNative &&
|
||||
{IS_NATIVE &&
|
||||
findContactsEnabled &&
|
||||
!gate('disable_settings_find_contacts') && (
|
||||
<SettingsList.LinkItem
|
||||
@@ -510,7 +510,7 @@ function DevOptions() {
|
||||
<Trans>Clear all storage data (restart after this)</Trans>
|
||||
</SettingsList.ItemText>
|
||||
</SettingsList.PressableItem>
|
||||
{isIOS ? (
|
||||
{IS_IOS ? (
|
||||
<SettingsList.PressableItem
|
||||
onPress={onPressApplyOta}
|
||||
label={_(msg`Apply Pull Request`)}>
|
||||
@@ -519,7 +519,7 @@ function DevOptions() {
|
||||
</SettingsList.ItemText>
|
||||
</SettingsList.PressableItem>
|
||||
) : null}
|
||||
{isNative && isCurrentlyRunningPullRequestDeployment ? (
|
||||
{IS_NATIVE && isCurrentlyRunningPullRequestDeployment ? (
|
||||
<SettingsList.PressableItem
|
||||
onPress={revertToEmbedded}
|
||||
label={_(msg`Unapply Pull Request`)}>
|
||||
|
||||
@@ -13,7 +13,6 @@ import {msg, Trans} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useMutation} from '@tanstack/react-query'
|
||||
|
||||
import {isWeb} from '#/platform/detection'
|
||||
import {useAppPasswordCreateMutation} from '#/state/queries/app-passwords'
|
||||
import {atoms as a, native, useTheme} from '#/alf'
|
||||
import {Admonition} from '#/components/Admonition'
|
||||
@@ -24,6 +23,7 @@ import * as Toggle from '#/components/forms/Toggle'
|
||||
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron'
|
||||
import {SquareBehindSquare4_Stroke2_Corner0_Rounded as CopyIcon} from '#/components/icons/SquareBehindSquare4'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {IS_WEB} from '#/env'
|
||||
import {CopyButton} from './CopyButton'
|
||||
|
||||
export function AddAppPasswordDialog({
|
||||
@@ -181,7 +181,7 @@ function CreateDialogInner({passwords}: {passwords: string[]}) {
|
||||
) : (
|
||||
<Animated.View
|
||||
style={[a.gap_lg]}
|
||||
entering={isWeb ? FadeIn.delay(200) : SlideInRight}
|
||||
entering={IS_WEB ? FadeIn.delay(200) : SlideInRight}
|
||||
key={1}>
|
||||
<Text style={[a.text_2xl, a.font_semi_bold]}>
|
||||
<Trans>Here is your app password!</Trans>
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as EmailValidator from 'email-validator'
|
||||
import {cleanError, isNetworkError} from '#/lib/strings/errors'
|
||||
import {checkAndFormatResetCode} from '#/lib/strings/password'
|
||||
import {logger} from '#/logger'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {useAgent, useSession} from '#/state/session'
|
||||
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
||||
import {android, atoms as a, web} from '#/alf'
|
||||
@@ -16,6 +15,7 @@ import * as Dialog from '#/components/Dialog'
|
||||
import * as TextField from '#/components/forms/TextField'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
|
||||
enum Stages {
|
||||
RequestCode = 'RequestCode',
|
||||
@@ -242,7 +242,7 @@ function Inner() {
|
||||
<Trans>Already have a code?</Trans>
|
||||
</ButtonText>
|
||||
</Button>
|
||||
{isNative && (
|
||||
{IS_NATIVE && (
|
||||
<Button
|
||||
label={_(msg`Cancel`)}
|
||||
color="secondary"
|
||||
|
||||
@@ -4,7 +4,6 @@ import {msg, Trans} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {useAgent, useSession} from '#/state/session'
|
||||
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
||||
import * as Toast from '#/view/com/util/Toast'
|
||||
@@ -15,6 +14,7 @@ import * as TextField from '#/components/forms/TextField'
|
||||
import {Lock_Stroke2_Corner0_Rounded as Lock} from '#/components/icons/Lock'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import {P, Text} from '#/components/Typography'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
|
||||
enum Stages {
|
||||
Email,
|
||||
@@ -193,7 +193,7 @@ export function DisableEmail2FADialog({
|
||||
</View>
|
||||
) : undefined}
|
||||
|
||||
{!gtMobile && isNative && <View style={{height: 40}} />}
|
||||
{!gtMobile && IS_NATIVE && <View style={{height: 40}} />}
|
||||
</View>
|
||||
</Dialog.ScrollableInner>
|
||||
</Dialog.Outer>
|
||||
|
||||
Reference in New Issue
Block a user