Fabric - Running on iOS and Android 🥳 (#3114)
* remove unused packages, switch to `expo-linear-gradient` * upgrade expo deps * rm blur view * re-add normalize-url * replace `react-native-version-number` with `expo-application` * add `expo-haptics` * rm `react-native-haptic-feedback` * migrate to `expo-haptics` * add `expo-clipboard` * migrate to `expo-clipboard` * add `expo-file-system` * migrate to `expo-file-system` and `expo-image-manipulator` passing tests remove other `react-native-fs` usages move to `expo-image-manipulator` for resizes remove react-native-image-resizer update tests update jest setup simplify some logic properly cleanup files migrate file downloads to `expo-file-system` rm `rn-fetch-blob` * delete file after uploading blob on native * fix file move error * add `react-native-date-picker` * rm `@reactnativecommunity/datetimepicker` * migrate to `react-native-date-picker` * use modal on android * fix android alf * use @discord/bottom-sheet * rm some patches * remove expo-dev-client * rm metro config changes that have been merged * Working build * ignore error for now * ignore error for now * add newArchEnabled flag * add types/invariant
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {BskyAgent, stringifyLex, jsonToLex} from '@atproto/api'
|
||||
import RNFS from 'react-native-fs'
|
||||
import {cacheDirectory, copyAsync, moveAsync} from 'expo-file-system'
|
||||
|
||||
const GET_TIMEOUT = 15e3 // 15s
|
||||
const POST_TIMEOUT = 60e3 // 60s
|
||||
@@ -33,9 +33,26 @@ async function fetchHandler(
|
||||
// we get around that by renaming the file ext to .bin
|
||||
// see https://github.com/facebook/react-native/issues/27099
|
||||
// -prf
|
||||
const newPath = reqBody.replace(/\.jpe?g$/, '.bin')
|
||||
await RNFS.moveFile(reqBody, newPath)
|
||||
reqBody = newPath
|
||||
|
||||
// On some platforms, moving this file is not possible. We will attempt to move it (this is optimal, since
|
||||
// we don't create duplicates) and if there is an error, we will instead copy the file to the cache directory
|
||||
const fileName = reqBody.split('/').pop() ?? ''
|
||||
const newPath = `${cacheDirectory ?? ''}${fileName.replace(
|
||||
/\.jpe?g$/,
|
||||
'.bin',
|
||||
)}`
|
||||
try {
|
||||
await moveAsync({
|
||||
from: reqBody,
|
||||
to: newPath,
|
||||
})
|
||||
reqBody = newPath
|
||||
} catch (e) {
|
||||
await copyAsync({
|
||||
from: reqBody,
|
||||
to: newPath,
|
||||
})
|
||||
}
|
||||
}
|
||||
// NOTE
|
||||
// React native treats bodies with {uri: string} as file uploads to pull from cache
|
||||
|
||||
Reference in New Issue
Block a user