Update sentry lines and comment new image picker.
This commit is contained in:
@@ -101,7 +101,7 @@ async function getPhotos({ bodyshop, jobid, setImages }) {
|
||||
|
||||
setImages(normalizedImages);
|
||||
} catch (error) {
|
||||
Sentry.Native.captureException(error);
|
||||
Sentry.captureException(error);
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: `Error fetching photos.`,
|
||||
|
||||
@@ -18,6 +18,9 @@ import JobSpaceAvailable from "../job-space-available/job-space-available.compon
|
||||
import UploadProgressLocal from "../upload-progress-local/upload-progress-local.component";
|
||||
import UploadDeleteSwitch from "../upload-delete-switch/upload-delete-switch.component";
|
||||
import UploadProgress from "../upload-progress/upload-progress.component";
|
||||
// import * as ImagePicker from "expo-image-picker";
|
||||
// import { Button } from "react-native-paper";
|
||||
// import * as MediaLibrary from "expo-media-library";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
selectedCameraJobId: selectCurrentCameraJobId,
|
||||
@@ -38,12 +41,29 @@ export function ImageBrowserScreen({
|
||||
const { t } = useTranslation();
|
||||
const [uploads, setUploads] = useState(null);
|
||||
const [tick, setTick] = useState(0);
|
||||
// const [medialLibraryPermissionStatus, requestmediaLibraryPermission] =
|
||||
// ImagePicker.useMediaLibraryPermissions();
|
||||
|
||||
const forceRerender = useCallback(() => {
|
||||
setTick((tick) => tick + 1);
|
||||
}, []);
|
||||
|
||||
const onDone = (data) => {
|
||||
logImEXEvent("imexmobile_upload_documents", { count: data.length });
|
||||
// const uploads = await Promise.all(
|
||||
// data.map(async (item) => {
|
||||
// let id = item.id || item.fileName;
|
||||
// if (!item.id && item.uri) {
|
||||
// id = await getAssetIdFromUri(item.uri, item.fileName);
|
||||
// }
|
||||
// return {
|
||||
// ...item,
|
||||
// localUri: item.uri,
|
||||
// id,
|
||||
// };
|
||||
// })
|
||||
// );
|
||||
// console.log("onDone", uploads);
|
||||
if (data.length !== 0) setUploads(data);
|
||||
};
|
||||
|
||||
@@ -73,25 +93,6 @@ export function ImageBrowserScreen({
|
||||
[]
|
||||
);
|
||||
|
||||
const widgetResize = useMemo(
|
||||
() => ({
|
||||
width: 50,
|
||||
compress: 0.7,
|
||||
base64: false,
|
||||
saveTo: "jpeg",
|
||||
}),
|
||||
[]
|
||||
);
|
||||
|
||||
const _textStyle = {
|
||||
color: "white",
|
||||
};
|
||||
|
||||
const _buttonStyle = {
|
||||
backgroundColor: "orange",
|
||||
borderRadius: 5,
|
||||
};
|
||||
|
||||
const widgetNavigator = useMemo(
|
||||
() => ({
|
||||
Texts: {
|
||||
@@ -134,6 +135,33 @@ export function ImageBrowserScreen({
|
||||
[]
|
||||
);
|
||||
|
||||
// const handleSelectPhotos = async () => {
|
||||
// let result = await ImagePicker.launchImageLibraryAsync({
|
||||
// mediaTypes: ["images", "videos"],
|
||||
// allowsMultipleSelection: true,
|
||||
// // aspect: [4, 3],
|
||||
// });
|
||||
// console.log("*** ~ handleSelectPhotos ~ result:", result);
|
||||
|
||||
// if (!result.canceled) {
|
||||
// const uploads = await Promise.all(
|
||||
// result.assets.map(async (item) => {
|
||||
// let id = item.id || item.fileName;
|
||||
// if (!item.id && item.uri) {
|
||||
// id = await getAssetIdFromUri(item.uri);
|
||||
// }
|
||||
// return {
|
||||
// ...item,
|
||||
// localUri: item.uri,
|
||||
// id,
|
||||
// };
|
||||
// })
|
||||
// );
|
||||
// console.log("Uploads from handleSelectPhotos", uploads);
|
||||
// setUploads(uploads);
|
||||
// }
|
||||
// };
|
||||
|
||||
return (
|
||||
<View style={[styles.flex, styles.container]}>
|
||||
<CameraSelectJob />
|
||||
@@ -147,16 +175,6 @@ export function ImageBrowserScreen({
|
||||
<JobSpaceAvailable jobid={selectedCameraJobId} key={`${tick}-space`} />
|
||||
)}
|
||||
<UploadDeleteSwitch />
|
||||
{
|
||||
// <Button
|
||||
// onPress={() => {
|
||||
// //Mutate the state
|
||||
// toggleDeleteAfterUpload();
|
||||
// }}
|
||||
// >
|
||||
// <Text>{`From screen. ${deleteAfterUpload}`}</Text>
|
||||
// </Button>
|
||||
}
|
||||
{!selectedCameraJobId && (
|
||||
<View
|
||||
style={{
|
||||
@@ -270,3 +288,32 @@ export default connect(mapStateToProps, mapDispatchToProps)(ImageBrowserScreen);
|
||||
// },
|
||||
// },
|
||||
// }}
|
||||
|
||||
// // Utility to get asset ID from URI if missing
|
||||
// async function getAssetIdFromUri(uri, filename = null, maxPages = 10) {
|
||||
// let after = null;
|
||||
// let found = null;
|
||||
// let pageCount = 0;
|
||||
|
||||
// while (!found && pageCount < maxPages) {
|
||||
// const page = await MediaLibrary.getAssetsAsync({
|
||||
// first: 100,
|
||||
// mediaType: [MediaLibrary.MediaType.photo, MediaLibrary.MediaType.video],
|
||||
// after,
|
||||
// });
|
||||
|
||||
// // Try to match by URI
|
||||
// found = page.assets.find((asset) => asset.uri === uri);
|
||||
|
||||
// // Fallback: try to match by filename if not found and filename is available
|
||||
// if (!found && filename) {
|
||||
// found = page.assets.find((asset) => asset.filename === filename);
|
||||
// }
|
||||
|
||||
// after = page.endCursor;
|
||||
// pageCount++;
|
||||
// if (!after) break;
|
||||
// }
|
||||
|
||||
// return found ? found.id : null;
|
||||
// }
|
||||
|
||||
@@ -79,7 +79,7 @@ export function UploadProgress({
|
||||
const deleteResult = await MediaLibrary.deleteAlbumsAsync(album);
|
||||
} catch (error) {
|
||||
console.log("Unable to delete picture.", error);
|
||||
Sentry.Native.captureException(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,10 +132,14 @@ export function UploadProgress({
|
||||
const data = [];
|
||||
const totalOfUploads = await selectedFiles.reduce(async (acc, val) => {
|
||||
//Get the size of the file based on URI.
|
||||
const info = await FileSystem.getInfoAsync(val.uri, { size: true });
|
||||
data.push({ ...info, ...val }); //Add in the size.
|
||||
val.albumId && MediaLibrary.migrateAlbumIfNeededAsync(val.albumId);
|
||||
return (await acc) + info.size;
|
||||
if (acc.fileSize) {
|
||||
return acc + acc.fileSize;
|
||||
} else {
|
||||
const info = await FileSystem.getInfoAsync(val.uri, { size: true });
|
||||
data.push({ ...info, ...val }); //Add in the size.
|
||||
val.albumId && MediaLibrary.migrateAlbumIfNeededAsync(val.albumId);
|
||||
return (await acc) + info.size;
|
||||
}
|
||||
}, 0);
|
||||
|
||||
if (selectedCameraJobId !== "temp") {
|
||||
@@ -231,7 +235,7 @@ export function UploadProgress({
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Unable to delete picture.", error);
|
||||
Sentry.Native.captureException(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
}
|
||||
filesToDelete = [];
|
||||
|
||||
Reference in New Issue
Block a user