Merge branch 'feature/IOS-7-documents-should-upload-in-chronol' into release/1.1.0
This commit is contained in:
6
app.json
6
app.json
@@ -2,18 +2,18 @@
|
||||
"expo": {
|
||||
"name": "imexmobile",
|
||||
"slug": "imexmobile",
|
||||
"version": "1.0.12",
|
||||
"version": "1.1.0",
|
||||
"orientation": "default",
|
||||
"icon": "./assets/logo192noa.png",
|
||||
"ios": {
|
||||
"supportsTablet": true,
|
||||
"bundleIdentifier": "com.imex.imexmobile",
|
||||
"buildNumber": "1.0.12",
|
||||
"buildNumber": "1.1.0.1",
|
||||
"googleServicesFile": "./GoogleService-Info.plist"
|
||||
},
|
||||
"android": {
|
||||
"package": "com.imex.imexmobile",
|
||||
"versionCode": 12,
|
||||
"versionCode": 1010001,
|
||||
"googleServicesFile": "./google-services.json"
|
||||
},
|
||||
"splash": {
|
||||
|
||||
@@ -52,12 +52,15 @@ export function ImageBrowserScreen({
|
||||
|
||||
const client = useApolloClient();
|
||||
async function handleOnSuccess(uri, id) {
|
||||
console.log("Succesful upload!", uri);
|
||||
logImEXEvent("imexmobile_successful_upload");
|
||||
setUploads((prevUploads) => _.omit(prevUploads, uri));
|
||||
}
|
||||
|
||||
const onDone = async (data) => {
|
||||
console.log(
|
||||
"🚀 ~ file: screen-media-browser.component.jsx ~ line 60 ~ data",
|
||||
data
|
||||
);
|
||||
logImEXEvent("imexmobile_upload_documents", { count: data.length });
|
||||
|
||||
//Validate to make sure the totals for the file sizes do not exceed the total on the job.
|
||||
@@ -74,20 +77,21 @@ export function ImageBrowserScreen({
|
||||
const totalOfUploads = await data.reduce(async (acc, val) => {
|
||||
//Get the size of the file based on URI.
|
||||
const info = await FileSystem.getInfoAsync(val.uri, { size: true });
|
||||
|
||||
return (await acc) + info.size;
|
||||
}, 0);
|
||||
|
||||
console.log(
|
||||
"Size of uploaded documents.",
|
||||
queryData.data.documents_aggregate.aggregate.sum.size,
|
||||
"Shop Limit",
|
||||
bodyshop.jobsizelimit,
|
||||
"Space remaining",
|
||||
bodyshop.jobsizelimit -
|
||||
queryData.data.documents_aggregate.aggregate.sum.size,
|
||||
"Total of uploaded files",
|
||||
totalOfUploads
|
||||
);
|
||||
// console.log(
|
||||
// "Size of uploaded documents.",
|
||||
// queryData.data.documents_aggregate.aggregate.sum.size,
|
||||
// "Shop Limit",
|
||||
// bodyshop.jobsizelimit,
|
||||
// "Space remaining",
|
||||
// bodyshop.jobsizelimit -
|
||||
// queryData.data.documents_aggregate.aggregate.sum.size,
|
||||
// "Total of uploaded files",
|
||||
// totalOfUploads
|
||||
// );
|
||||
|
||||
if (
|
||||
bodyshop.jobsizelimit -
|
||||
@@ -108,12 +112,12 @@ export function ImageBrowserScreen({
|
||||
let filename;
|
||||
//Appears to work for android.
|
||||
//iOS provides the filename, android doe snot.
|
||||
console.log("pid", p.id);
|
||||
|
||||
filename = p.filename || p.uri.split("/").pop();
|
||||
const result = await handleUpload(
|
||||
{
|
||||
//iOS provides the file name. Android does not.
|
||||
uri: p.uri,
|
||||
|
||||
filename,
|
||||
mediaId: p.id,
|
||||
onError: handleOnError,
|
||||
@@ -133,10 +137,7 @@ export function ImageBrowserScreen({
|
||||
|
||||
if (deleteAfterUpload) {
|
||||
try {
|
||||
const result = await MediaLibrary.deleteAssetsAsync(
|
||||
ret.map((r) => r.mediaId)
|
||||
);
|
||||
console.log("Delete result :>> ", result);
|
||||
await MediaLibrary.deleteAssetsAsync(ret.map((r) => r.mediaId));
|
||||
} catch (error) {
|
||||
console.log("Unable to delete picture.", error);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import Constants from "expo-constants";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button, View } from "react-native";
|
||||
import { Button, View, Text } from "react-native";
|
||||
import { Title } from "react-native-paper";
|
||||
import { purgeStoredState } from "redux-persist";
|
||||
import SignOutButton from "../sign-out-button/sign-out-button.component";
|
||||
import * as Updates from "expo-updates";
|
||||
|
||||
export default function ScreenSettingsComponent() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
console.log(Constants.manifest);
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -22,6 +26,7 @@ export default function ScreenSettingsComponent() {
|
||||
number: Constants.manifest.version,
|
||||
})}
|
||||
</Title>
|
||||
<Text>{Updates.releaseChannel}</Text>
|
||||
<SignOutButton />
|
||||
<Button title="Purge State" onPress={() => purgeStoredState()} />
|
||||
</View>
|
||||
|
||||
22
env.js
22
env.js
@@ -1,5 +1,7 @@
|
||||
import * as Updates from "expo-updates";
|
||||
|
||||
const ENV = {
|
||||
dev: {
|
||||
test: {
|
||||
API_URL: "https://api.test.imex.online",
|
||||
uri: "https://db.test.bodyshop.app/v1/graphql",
|
||||
wsuri: "wss://db.test.bodyshop.app/v1/graphql",
|
||||
@@ -42,11 +44,19 @@ const ENV = {
|
||||
};
|
||||
|
||||
function getEnvVars() {
|
||||
let env = process.env.NODE_ENV;
|
||||
if (env === null || env === undefined || env === "") return ENV.dev;
|
||||
if (env.indexOf("dev") !== -1) return ENV.dev;
|
||||
if (env.indexOf("staging") !== -1) return ENV.staging;
|
||||
if (env.indexOf("prod") !== -1) return ENV.prod;
|
||||
if (process.env.NODE_ENV === "development") return ENV.test;
|
||||
|
||||
let releaseChannel = Updates.releaseChannel;
|
||||
if (
|
||||
releaseChannel === null ||
|
||||
releaseChannel === undefined ||
|
||||
releaseChannel === ""
|
||||
)
|
||||
return ENV.test;
|
||||
if (releaseChannel.indexOf("development") !== -1) return ENV.test;
|
||||
|
||||
if (releaseChannel.indexOf("test") !== -1) return ENV.test;
|
||||
if (releaseChannel.indexOf("default") !== -1) return ENV.prod;
|
||||
else return ENV.prod;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ const INITIAL_STATE = {
|
||||
cameraJob: null,
|
||||
documentUploadInProgress: null,
|
||||
documentUploadError: null,
|
||||
deleteAfterUpload: true,
|
||||
deleteAfterUpload: false,
|
||||
};
|
||||
|
||||
const appReducer = (state = INITIAL_STATE, action) => {
|
||||
|
||||
@@ -12,19 +12,24 @@ var cleanAxios = axios.create();
|
||||
cleanAxios.interceptors.request.eject(axiosAuthInterceptorId);
|
||||
|
||||
export const handleUpload = async (ev, context) => {
|
||||
const { uri, filename, mediaId, onError, onSuccess, onProgress } = ev;
|
||||
const { filename, mediaId, onError, onSuccess, onProgress } = ev;
|
||||
const { bodyshop, jobId } = context;
|
||||
|
||||
const newFile = await (await fetch(uri)).blob();
|
||||
let extension = ev.uri.split(".").pop();
|
||||
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
|
||||
|
||||
const newFile = await (await fetch(imageData.localUri)).blob();
|
||||
|
||||
let extension = imageData.localUri.split(".").pop();
|
||||
|
||||
let key = `${bodyshop.id}/${jobId}/${(filename || newFile.data.name).replace(
|
||||
/\.[^/.]+$/,
|
||||
""
|
||||
)}`;
|
||||
|
||||
const res = await uploadToCloudinary(
|
||||
key,
|
||||
mediaId,
|
||||
imageData,
|
||||
extension,
|
||||
newFile.type,
|
||||
newFile,
|
||||
@@ -39,6 +44,7 @@ export const handleUpload = async (ev, context) => {
|
||||
export const uploadToCloudinary = async (
|
||||
key,
|
||||
mediaId,
|
||||
imageData,
|
||||
extension,
|
||||
fileType,
|
||||
file,
|
||||
@@ -57,7 +63,7 @@ export const uploadToCloudinary = async (
|
||||
tagsArray ? tagsArray.map((tag) => `${tag},`) : ""
|
||||
}`;
|
||||
// let eager = process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS;
|
||||
console.log("fileType", fileType);
|
||||
|
||||
const upload_preset = fileType.startsWith("video")
|
||||
? "incoming_upload_video"
|
||||
: "incoming_upload";
|
||||
@@ -91,10 +97,11 @@ export const uploadToCloudinary = async (
|
||||
if (onProgress) onProgress({ percent: e.loaded / e.total });
|
||||
},
|
||||
};
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append("file", {
|
||||
uri: photo.uri,
|
||||
uri: imageData.localUri,
|
||||
type: fileType,
|
||||
name: file.data.name,
|
||||
});
|
||||
@@ -134,12 +141,7 @@ export const uploadToCloudinary = async (
|
||||
if (onError) onError(cloudinaryUploadResponse.statusText);
|
||||
return { success: false, error: cloudinaryUploadResponse.statusText };
|
||||
}
|
||||
console.log("mediaId", mediaId);
|
||||
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
|
||||
console.log(
|
||||
"🚀 ~ file: document-upload.utility.js ~ line 140 ~ imageData",
|
||||
imageData.creationTime
|
||||
);
|
||||
|
||||
//Insert the document with the matching key.
|
||||
const documentInsert = await client.mutate({
|
||||
mutation: INSERT_NEW_DOCUMENT,
|
||||
|
||||
Reference in New Issue
Block a user