Remove debugging statements.
This commit is contained in:
4
app.json
4
app.json
@@ -4,7 +4,7 @@
|
|||||||
"slug": "imexmobile",
|
"slug": "imexmobile",
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"extra": {
|
"extra": {
|
||||||
"expover": "4",
|
"expover": "5",
|
||||||
"eas": {
|
"eas": {
|
||||||
"projectId": "ffe01f3a-d507-4698-82cd-da1f1cad450b"
|
"projectId": "ffe01f3a-d507-4698-82cd-da1f1cad450b"
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
"android": {
|
"android": {
|
||||||
"package": "com.imex.imexmobile",
|
"package": "com.imex.imexmobile",
|
||||||
"versionCode": 1100029,
|
"versionCode": 1100030,
|
||||||
"googleServicesFile": "./google-services.json",
|
"googleServicesFile": "./google-services.json",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"android.permission.READ_EXTERNAL_STORAGE",
|
"android.permission.READ_EXTERNAL_STORAGE",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as MediaLibrary from "expo-media-library";
|
import * as MediaLibrary from 'expo-media-library';
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
@@ -8,20 +8,20 @@ import {
|
|||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} from "react-native";
|
} from 'react-native';
|
||||||
import { ProgressBar } from "react-native-paper";
|
import { ProgressBar } from 'react-native-paper';
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from 'react-native-toast-message';
|
||||||
import { connect } from "react-redux";
|
import { connect } from 'react-redux';
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from 'reselect';
|
||||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
import { logImEXEvent } from '../../firebase/firebase.analytics';
|
||||||
import {
|
import {
|
||||||
selectCurrentCameraJobId,
|
selectCurrentCameraJobId,
|
||||||
selectDeleteAfterUpload,
|
selectDeleteAfterUpload,
|
||||||
} from "../../redux/app/app.selectors";
|
} from '../../redux/app/app.selectors';
|
||||||
import * as Sentry from '@sentry/react-native';
|
import * as Sentry from '@sentry/react-native';
|
||||||
|
|
||||||
import { formatBytes } from "../../util/document-upload.utility";
|
import { formatBytes } from '../../util/document-upload.utility';
|
||||||
import { handleLocalUpload } from "../../util/local-document-upload.utility";
|
import { handleLocalUpload } from '../../util/local-document-upload.utility';
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
selectedCameraJobId: selectCurrentCameraJobId,
|
selectedCameraJobId: selectCurrentCameraJobId,
|
||||||
@@ -54,7 +54,7 @@ export function UploadProgress({
|
|||||||
async function handleOnSuccess({ duration, data }) {
|
async function handleOnSuccess({ duration, data }) {
|
||||||
//If it's not in production, show a toast with the time.
|
//If it's not in production, show a toast with the time.
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: 'success',
|
||||||
text1: ` Upload completed in ${duration}.`,
|
text1: ` Upload completed in ${duration}.`,
|
||||||
//
|
//
|
||||||
// text2: duration,
|
// text2: duration,
|
||||||
@@ -63,45 +63,27 @@ export function UploadProgress({
|
|||||||
try {
|
try {
|
||||||
await MediaLibrary.deleteAssetsAsync(data);
|
await MediaLibrary.deleteAssetsAsync(data);
|
||||||
|
|
||||||
|
const album = await MediaLibrary.createAlbumAsync(
|
||||||
try {
|
'ImEX Mobile Deleted',
|
||||||
const album = await MediaLibrary.createAlbumAsync(
|
data.pop(),
|
||||||
'ImEX Mobile Deleted',
|
false
|
||||||
data.pop(),
|
);
|
||||||
|
//Move the rest.
|
||||||
|
if (data.length > 0) {
|
||||||
|
const moveResult = await MediaLibrary.addAssetsToAlbumAsync(
|
||||||
|
data,
|
||||||
|
album,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
//Move the rest.
|
|
||||||
if (data.length > 0) {
|
|
||||||
const moveResult = await MediaLibrary.addAssetsToAlbumAsync(
|
|
||||||
data,
|
|
||||||
album,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const deleteResult = await MediaLibrary.deleteAlbumsAsync(album);
|
|
||||||
Toast.show({
|
|
||||||
type: 'success',
|
|
||||||
text1: 'Pictures deleted succesfully.',
|
|
||||||
text2: JSON.stringify(deleteResult),
|
|
||||||
autoHide: false,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log("🚀 ~ onDone ~ error:", error)
|
|
||||||
Toast.show({
|
|
||||||
type: 'error',
|
|
||||||
text1: 'deleteAlbumsAsync',
|
|
||||||
text2: JSON.stringify(error),
|
|
||||||
autoHide: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const deleteResult = await MediaLibrary.deleteAlbumsAsync(album);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Unable to delete picture.", error);
|
console.log('Unable to delete picture.', error);
|
||||||
Sentry.Native.captureException(error);
|
Sentry.Native.captureException(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logImEXEvent("imexmobile_successful_upload");
|
logImEXEvent('imexmobile_successful_upload');
|
||||||
forceRerender();
|
forceRerender();
|
||||||
setProgress({ ...progress, speed: 0, percent: 1, uploadInProgress: false });
|
setProgress({ ...progress, speed: 0, percent: 1, uploadInProgress: false });
|
||||||
}
|
}
|
||||||
@@ -116,10 +98,10 @@ export function UploadProgress({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleOnError({ assetid, error }) {
|
function handleOnError({ assetid, error }) {
|
||||||
logImEXEvent("imexmobile_upload_documents_error");
|
logImEXEvent('imexmobile_upload_documents_error');
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "error",
|
type: 'error',
|
||||||
text1: "Unable to upload documents.",
|
text1: 'Unable to upload documents.',
|
||||||
text2: error,
|
text2: error,
|
||||||
autoHide: false,
|
autoHide: false,
|
||||||
});
|
});
|
||||||
@@ -148,7 +130,7 @@ export function UploadProgress({
|
|||||||
onSuccess: ({ duration }) => handleOnSuccess({ duration, data }),
|
onSuccess: ({ duration }) => handleOnSuccess({ duration, data }),
|
||||||
context: {
|
context: {
|
||||||
jobid:
|
jobid:
|
||||||
selectedCameraJobId !== "temp" ? selectedCameraJobId : "temporary",
|
selectedCameraJobId !== 'temp' ? selectedCameraJobId : 'temporary',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -156,41 +138,41 @@ export function UploadProgress({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={progress.uploadInProgress}
|
visible={progress.uploadInProgress}
|
||||||
animationType="slide"
|
animationType='slide'
|
||||||
transparent={true}
|
transparent={true}
|
||||||
onRequestClose={() => {
|
onRequestClose={() => {
|
||||||
Alert.alert("Cancel?", "Do you want to abort the upload?", [
|
Alert.alert('Cancel?', 'Do you want to abort the upload?', [
|
||||||
{
|
{
|
||||||
text: "Yes",
|
text: 'Yes',
|
||||||
onPress: () => {
|
onPress: () => {
|
||||||
setUploads(null);
|
setUploads(null);
|
||||||
setProgress(null);
|
setProgress(null);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ text: "No" },
|
{ text: 'No' },
|
||||||
]);
|
]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View style={styles.modalContainer}>
|
<View style={styles.modalContainer}>
|
||||||
<View style={styles.modal}>
|
<View style={styles.modal}>
|
||||||
<ActivityIndicator style={{ alignSelf: "center", marginTop: 16 }} />
|
<ActivityIndicator style={{ alignSelf: 'center', marginTop: 16 }} />
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
progress={progress.percent}
|
progress={progress.percent}
|
||||||
style={{ alignSelf: "center", marginTop: 16 }}
|
style={{ alignSelf: 'center', marginTop: 16 }}
|
||||||
color={progress.percent === 1 ? "green" : "blue"}
|
color={progress.percent === 1 ? 'green' : 'blue'}
|
||||||
/>
|
/>
|
||||||
<Text style={{ alignSelf: "center", marginTop: 16 }}>{`${formatBytes(
|
<Text style={{ alignSelf: 'center', marginTop: 16 }}>{`${formatBytes(
|
||||||
progress.speed
|
progress.speed
|
||||||
)}/sec`}</Text>
|
)}/sec`}</Text>
|
||||||
<Text
|
<Text
|
||||||
style={{ alignSelf: "center", marginTop: 16 }}
|
style={{ alignSelf: 'center', marginTop: 16 }}
|
||||||
>{`Avg. ${formatBytes(
|
>{`Avg. ${formatBytes(
|
||||||
progress.loaded / ((new Date() - progress.start) / 1000)
|
progress.loaded / ((new Date() - progress.start) / 1000)
|
||||||
)}/sec`}</Text>
|
)}/sec`}</Text>
|
||||||
<Text
|
<Text
|
||||||
style={{ alignSelf: "center", marginTop: 16 }}
|
style={{ alignSelf: 'center', marginTop: 16 }}
|
||||||
>{`Total Uploaded ${formatBytes(progress.loaded)}`}</Text>
|
>{`Total Uploaded ${formatBytes(progress.loaded)}`}</Text>
|
||||||
<Text style={{ alignSelf: "center", marginTop: 16 }}>{`Duration ${(
|
<Text style={{ alignSelf: 'center', marginTop: 16 }}>{`Duration ${(
|
||||||
(new Date() - progress.start) /
|
(new Date() - progress.start) /
|
||||||
1000
|
1000
|
||||||
).toFixed(1)} sec`}</Text>
|
).toFixed(1)} sec`}</Text>
|
||||||
@@ -201,19 +183,19 @@ export function UploadProgress({
|
|||||||
}
|
}
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
modalContainer: {
|
modalContainer: {
|
||||||
display: "flex",
|
display: 'flex',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: "center",
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
modal: {
|
modal: {
|
||||||
// flex: 1,
|
// flex: 1,
|
||||||
display: "flex",
|
display: 'flex',
|
||||||
marginLeft: 20,
|
marginLeft: 20,
|
||||||
marginRight: 20,
|
marginRight: 20,
|
||||||
backgroundColor: "white",
|
backgroundColor: 'white',
|
||||||
borderRadius: 20,
|
borderRadius: 20,
|
||||||
padding: 18,
|
padding: 18,
|
||||||
shadowColor: "#000",
|
shadowColor: '#000',
|
||||||
shadowOffset: {
|
shadowOffset: {
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 2,
|
height: 2,
|
||||||
|
|||||||
@@ -208,100 +208,22 @@ export function UploadProgress({
|
|||||||
//Create a new asset with the first file to delete.
|
//Create a new asset with the first file to delete.
|
||||||
// console.log('Trying new delete.');
|
// console.log('Trying new delete.');
|
||||||
await MediaLibrary.getPermissionsAsync(false);
|
await MediaLibrary.getPermissionsAsync(false);
|
||||||
// try {
|
|
||||||
// const albumremove = await MediaLibrary.removeAssetsFromAlbumAsync(
|
|
||||||
// filesToDelete,
|
|
||||||
// filesToDelete[0].albumId
|
|
||||||
// );
|
|
||||||
// Toast.show({
|
|
||||||
// type: 'info',
|
|
||||||
// text1: 'removeAssetsFromAlbumAsync',
|
|
||||||
// text2: JSON.stringify(albumremove),
|
|
||||||
// autoHide: false,
|
|
||||||
// });
|
|
||||||
// } catch (error) {
|
|
||||||
// console.log("🚀 ~ onDone ~ error:", error)
|
|
||||||
// Toast.show({
|
|
||||||
// type: 'error',
|
|
||||||
// text1: 'removeAssetsFromAlbumAsync',
|
|
||||||
// text2: JSON.stringify(error),
|
|
||||||
// autoHide: false,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// try {
|
const album = await MediaLibrary.createAlbumAsync(
|
||||||
// const delres = await MediaLibrary.deleteAssetsAsync(
|
'ImEX Mobile Deleted',
|
||||||
// filesToDelete.map((f) => f.id)
|
filesToDelete.pop(),
|
||||||
// );
|
false
|
||||||
|
);
|
||||||
// Toast.show({
|
//Move the rest.
|
||||||
// type: 'info',
|
if (filesToDelete.length > 0) {
|
||||||
// text1: 'deleteAssetsAsync',
|
const moveResult = await MediaLibrary.addAssetsToAlbumAsync(
|
||||||
// text2: JSON.stringify(delres),
|
filesToDelete,
|
||||||
// autoHide: false,
|
album,
|
||||||
// });
|
|
||||||
// } catch (error) {
|
|
||||||
// console.log("🚀 ~ onDone ~ error:", error)
|
|
||||||
// Toast.show({
|
|
||||||
// type: 'error',
|
|
||||||
// text1: 'deleteAssetsAsync',
|
|
||||||
// text2: JSON.stringify(error),
|
|
||||||
// autoHide: false,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// const res = Promise.all(
|
|
||||||
// filesToDelete.map((f) =>
|
|
||||||
// FileSystem.deleteAsync(f.uri, { idempotent: true })
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// Toast.show({
|
|
||||||
// type: 'info',
|
|
||||||
// text1: 'FileSystemDelete',
|
|
||||||
// text2: JSON.stringify(res),
|
|
||||||
// autoHide: false,
|
|
||||||
// });
|
|
||||||
// } catch (error) {
|
|
||||||
// console.log("🚀 ~ onDone ~ error:", error)
|
|
||||||
// Toast.show({
|
|
||||||
// type: 'error',
|
|
||||||
// text1: 'FileSystemDelete',
|
|
||||||
// text2: JSON.stringify(error),
|
|
||||||
// autoHide: false,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
try {
|
|
||||||
const album = await MediaLibrary.createAlbumAsync(
|
|
||||||
'ImEX Mobile Deleted',
|
|
||||||
filesToDelete.pop(),
|
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
//Move the rest.
|
|
||||||
if (filesToDelete.length > 0) {
|
|
||||||
const moveResult = await MediaLibrary.addAssetsToAlbumAsync(
|
|
||||||
filesToDelete,
|
|
||||||
album,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const deleteResult = await MediaLibrary.deleteAlbumsAsync(album);
|
|
||||||
Toast.show({
|
|
||||||
type: 'success',
|
|
||||||
text1: 'Pictures deleted succesfully.',
|
|
||||||
text2: JSON.stringify(deleteResult),
|
|
||||||
autoHide: false,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log("🚀 ~ onDone ~ error:", error)
|
|
||||||
Toast.show({
|
|
||||||
type: 'error',
|
|
||||||
text1: 'deleteAlbumsAsync',
|
|
||||||
text2: JSON.stringify(error),
|
|
||||||
autoHide: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const deleteResult = await MediaLibrary.deleteAlbumsAsync(album);
|
||||||
|
|
||||||
//Delete the album.
|
//Delete the album.
|
||||||
|
|
||||||
//This defaults to delete all assets in the album.
|
//This defaults to delete all assets in the album.
|
||||||
|
|||||||
Reference in New Issue
Block a user