Move /platform/detection vars into /env (#9707)
* Add platform vars to env * Replace /platform/detection with /env
This commit is contained in:
@@ -18,7 +18,7 @@ import {Buffer} from 'buffer'
|
||||
|
||||
import {POST_IMG_MAX} from '#/lib/constants'
|
||||
import {logger} from '#/logger'
|
||||
import {isAndroid, isIOS} from '#/platform/detection'
|
||||
import {IS_ANDROID, IS_IOS} from '#/env'
|
||||
import {type PickerImage} from './picker.shared'
|
||||
import {type Dimensions} from './types'
|
||||
|
||||
@@ -108,7 +108,7 @@ export async function saveImageToMediaLibrary({uri}: {uri: string}) {
|
||||
|
||||
// save
|
||||
try {
|
||||
if (isAndroid) {
|
||||
if (IS_ANDROID) {
|
||||
// android triggers an annoying permission prompt if you try and move an image
|
||||
// between albums. therefore, we need to either create the album with the image
|
||||
// as the starting image, or put it directly into the album
|
||||
@@ -305,7 +305,7 @@ function joinPath(a: string, b: string) {
|
||||
}
|
||||
|
||||
function normalizePath(str: string, allPlatforms = false): string {
|
||||
if (isAndroid || allPlatforms) {
|
||||
if (IS_ANDROID || allPlatforms) {
|
||||
if (!str.startsWith('file://')) {
|
||||
return `file://${str}`
|
||||
}
|
||||
@@ -328,7 +328,7 @@ export async function saveToDevice(
|
||||
type: string,
|
||||
) {
|
||||
try {
|
||||
if (isIOS) {
|
||||
if (IS_IOS) {
|
||||
await withTempFile(filename, encoded, async tmpFileUrl => {
|
||||
await Sharing.shareAsync(tmpFileUrl, {UTI: type})
|
||||
})
|
||||
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
} from 'expo-image-picker'
|
||||
import {t} from '@lingui/macro'
|
||||
|
||||
import {isIOS, isWeb} from '#/platform/detection'
|
||||
import {type ImageMeta} from '#/state/gallery'
|
||||
import * as Toast from '#/view/com/util/Toast'
|
||||
import {IS_IOS, IS_WEB} from '#/env'
|
||||
import {VIDEO_MAX_DURATION_MS} from '../constants'
|
||||
import {getDataUriSize} from './util'
|
||||
|
||||
@@ -53,8 +53,8 @@ export async function openUnifiedPicker({
|
||||
quality: 1,
|
||||
allowsMultipleSelection: true,
|
||||
legacy: true,
|
||||
base64: isWeb,
|
||||
selectionLimit: isIOS ? selectionCountRemaining : undefined,
|
||||
base64: IS_WEB,
|
||||
selectionLimit: IS_IOS ? selectionCountRemaining : undefined,
|
||||
preferredAssetRepresentationMode:
|
||||
UIImagePickerPreferredAssetRepresentationMode.Automatic,
|
||||
videoMaxDuration: VIDEO_MAX_DURATION_MS / 1000,
|
||||
|
||||
@@ -2,8 +2,8 @@ import {useCallback} from 'react'
|
||||
import {msg} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {isNative} from '#/platform/detection'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {saveImageToMediaLibrary} from './manip'
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ export function useSaveImageToMediaLibrary() {
|
||||
const {_} = useLingui()
|
||||
return useCallback(
|
||||
async (uri: string) => {
|
||||
if (!isNative) {
|
||||
if (!IS_NATIVE) {
|
||||
throw new Error('useSaveImageToMediaLibrary is native only')
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import * as MediaLibrary from 'expo-media-library'
|
||||
import {msg} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {isNative} from '#/platform/detection'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {saveImageToMediaLibrary} from './manip'
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ export function useSaveImageToMediaLibrary() {
|
||||
})
|
||||
return useCallback(
|
||||
async (uri: string) => {
|
||||
if (!isNative) {
|
||||
if (!IS_NATIVE) {
|
||||
throw new Error('useSaveImageToMediaLibrary is native only')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user