154 cached image profile (#167)

* Fixes issue where retrying on image upload fails

* Lint, longer test time

* Longer waitfor time in tests

* even longer timeout

* longer timeout

* missed file

* Fixes image cache error on second try for profile screen

* lint

* lint

* lint
This commit is contained in:
Aryan Goharzad
2023-02-07 15:29:33 -05:00
committed by GitHub
parent 2ac6cae63a
commit 0e160298c8
2 changed files with 26 additions and 18 deletions
+6 -16
View File
@@ -1,13 +1,12 @@
import React, {useCallback} from 'react'
import {Image, StyleSheet, TouchableOpacity, ScrollView} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import uuid from 'react-native-uuid'
import {useAnalytics} from '@segment/analytics-react-native'
import {
openPicker,
openCamera,
openCropper,
} from 'react-native-image-crop-picker'
import RNFS from 'react-native-fs'
import {
UserLocalPhotosModel,
PhotoIdentifier,
@@ -16,10 +15,13 @@ import {
requestPhotoAccessIfNeeded,
requestCameraAccessIfNeeded,
} from '../../../lib/permissions'
import {compressIfNeeded, scaleDownDimensions} from '../../../lib/images'
import {
compressIfNeeded,
moveToPremanantPath,
scaleDownDimensions,
} from '../../../lib/images'
import {usePalette} from '../../lib/hooks/usePalette'
import {useStores} from '../../../state'
import {useAnalytics} from '@segment/analytics-react-native'
const MAX_WIDTH = 2000
const MAX_HEIGHT = 2000
@@ -33,18 +35,6 @@ const IMAGE_PARAMS = {
compressImageQuality: 1.0,
}
const moveToPremanantPath = async (path: string) => {
/*
Since this package stores images in a temp directory, we need to move the file to a permanent location.
Relevant: IOS bug when trying to open a second time:
https://github.com/ivpusic/react-native-image-crop-picker/issues/1199
*/
const filename = uuid.v4()
const destinationPath = `${RNFS.TemporaryDirectoryPath}/${filename}`
RNFS.moveFile(path, destinationPath)
return destinationPath
}
export async function cropPhoto(
path: string,
imgWidth = MAX_WIDTH,