my fork of the bluesky client
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove `react-native-fs` (#5463)

* remove rnfs

* tweak e2e

* log

* use `safeDeleteAsync`

authored by hailey.at and committed by

GitHub d2fae81b b9516202

+29 -29
-1
package.json
··· 175 175 "react-native-compressor": "^1.8.24", 176 176 "react-native-date-picker": "^4.4.2", 177 177 "react-native-drawer-layout": "^4.0.0-alpha.3", 178 - "react-native-fs": "^2.20.0", 179 178 "react-native-gesture-handler": "~2.16.2", 180 179 "react-native-get-random-values": "~1.11.0", 181 180 "react-native-image-crop-picker": "0.41.2",
+5 -3
src/lib/api/upload-blob.ts
··· 1 - import RNFS from 'react-native-fs' 1 + import {copyAsync} from 'expo-file-system' 2 2 import {BskyAgent, ComAtprotoRepoUploadBlob} from '@atproto/api' 3 + 4 + import {safeDeleteAsync} from '#/lib/media/manip' 3 5 4 6 /** 5 7 * @param encoding Allows overriding the blob's type ··· 65 67 // temporary file). 66 68 const newPath = uri.replace(/\.jpe?g$/, '.bin') 67 69 try { 68 - await RNFS.copyFile(uri, newPath) 70 + await copyAsync({from: uri, to: newPath}) 69 71 } catch { 70 72 // Failed to copy the file, just use the original 71 73 return await fn(uri) ··· 74 76 return await fn(newPath) 75 77 } finally { 76 78 // Remove the temporary file 77 - await RNFS.unlink(newPath) 79 + await safeDeleteAsync(newPath) 78 80 } 79 81 } else { 80 82 return fn(uri)
+23 -11
src/lib/media/picker.e2e.tsx
··· 1 - import RNFS from 'react-native-fs' 2 1 import { 3 2 Image as RNImage, 4 3 openCropper as openCropperFn, 5 4 } from 'react-native-image-crop-picker' 5 + import { 6 + documentDirectory, 7 + getInfoAsync, 8 + readDirectoryAsync, 9 + } from 'expo-file-system' 6 10 7 11 import {compressIfNeeded} from './manip' 8 12 import {CropperOptions} from './types' 9 13 10 14 async function getFile() { 11 - let files = await RNFS.readDir( 12 - RNFS.LibraryDirectoryPath.split('/') 13 - .slice(0, -5) 14 - .concat(['Media', 'DCIM', '100APPLE']) 15 - .join('/'), 16 - ) 17 - files = files.filter(file => file.path.endsWith('.JPG')) 18 - const file = files[0] 15 + const imagesDir = documentDirectory! 16 + .split('/') 17 + .slice(0, -6) 18 + .concat(['Media', 'DCIM', '100APPLE']) 19 + .join('/') 20 + 21 + let files = await readDirectoryAsync(imagesDir) 22 + files = files.filter(file => file.endsWith('.JPG')) 23 + const file = `${imagesDir}/${files[0]}` 24 + 25 + const fileInfo = await getInfoAsync(file) 26 + 27 + if (!fileInfo.exists) { 28 + throw new Error('Failed to get file info') 29 + } 30 + 19 31 return await compressIfNeeded({ 20 - path: file.path, 32 + path: file, 21 33 mime: 'image/jpeg', 22 - size: file.size, 34 + size: fileInfo.size, 23 35 width: 4288, 24 36 height: 2848, 25 37 })
+1 -14
yarn.lock
··· 9540 9540 resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" 9541 9541 integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== 9542 9542 9543 - base-64@0.1.0, base-64@^0.1.0: 9543 + base-64@0.1.0: 9544 9544 version "0.1.0" 9545 9545 resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb" 9546 9546 integrity sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA== ··· 19038 19038 dependencies: 19039 19039 use-latest-callback "^0.1.9" 19040 19040 19041 - react-native-fs@^2.20.0: 19042 - version "2.20.0" 19043 - resolved "https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.20.0.tgz#05a9362b473bfc0910772c0acbb73a78dbc810f6" 19044 - integrity sha512-VkTBzs7fIDUiy/XajOSNk0XazFE9l+QlMAce7lGuebZcag5CnjszB+u4BdqzwaQOdcYb5wsJIsqq4kxInIRpJQ== 19045 - dependencies: 19046 - base-64 "^0.1.0" 19047 - utf8 "^3.0.0" 19048 - 19049 19041 react-native-gesture-handler@~2.16.2: 19050 19042 version "2.16.2" 19051 19043 resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.16.2.tgz#032bd2a07334292d7f6cff1dc9d1ec928f72e26d" ··· 21829 21821 dependencies: 21830 21822 detect-node-es "^1.1.0" 21831 21823 tslib "^2.0.0" 21832 - 21833 - utf8@^3.0.0: 21834 - version "3.0.0" 21835 - resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" 21836 - integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ== 21837 21824 21838 21825 util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: 21839 21826 version "1.0.2"