diff --git a/App.js b/App.js index 5c15815..c94c6a9 100644 --- a/App.js +++ b/App.js @@ -11,8 +11,6 @@ import { client } from "./graphql/client"; import { persistor, store } from "./redux/store"; import "./translations/i18n"; -console.log("Environment Variables Set:", env); - Sentry.init({ dsn: "https://8d6c3de1940a4e4f8b81cf4d2150bdea@o492140.ingest.sentry.io/5558869", diff --git a/components/job-documents/job-documents.component.jsx b/components/job-documents/job-documents.component.jsx index 842ef18..687f4d2 100644 --- a/components/job-documents/job-documents.component.jsx +++ b/components/job-documents/job-documents.component.jsx @@ -1,4 +1,4 @@ -import React, { useState, useMemo } from "react"; +import React, { useMemo, useState } from "react"; import { FlatList, Image, @@ -32,6 +32,8 @@ export default function JobDocumentsComponent({ job, loading, refetch }) { [job.documents] ); + console.log("fullphotos", fullphotos); + return ( item.id} renderItem={(object) => ( ({ @@ -20,35 +17,35 @@ const mapDispatchToProps = (dispatch) => ({ export function JobListItem({ setCameraJob, setCameraJobId, item }) { const { t } = useTranslation(); const navigation = useNavigation(); - const _swipeableRow = useRef(null); + // const _swipeableRow = useRef(null); - const RenderRightAction = (progress, dragX) => { - const scale = dragX.interpolate({ - inputRange: [-100, 0], - outputRange: [0.7, 0], - }); + // const RenderRightAction = (progress, dragX) => { + // const scale = dragX.interpolate({ + // inputRange: [-100, 0], + // outputRange: [0.7, 0], + // }); - return ( - { - logImEXEvent("imexmobile_setcamerajobid_swipe"); - setCameraJobId(item.id); - setCameraJob(item); - navigation.navigate("MediaBrowserTab"); - _swipeableRow.current.close(); - }} - > - - - - - ); - }; + // return ( + // { + // logImEXEvent("imexmobile_setcamerajobid_swipe"); + // setCameraJobId(item.id); + // setCameraJob(item); + // navigation.navigate("MediaBrowserTab"); + // _swipeableRow.current.close(); + // }} + // > + // + // + // + // + // ); + // }; const onPress = () => { logImEXEvent("imexmobile_view_job_detail"); @@ -59,35 +56,33 @@ export function JobListItem({ setCameraJob, setCameraJobId, item }) { }; return ( - - {item.ro_number || t("general.labels.na")}} - description={`${item.ownr_fn || ""} ${item.ownr_ln || ""} ${ - item.ownr_co_nm || "" - } - ${item.v_model_yr || ""} ${item.v_make_desc || ""} ${ - item.v_model_desc || "" - }`} - right={({ style }) => ( - - )} - /> - + {item.ro_number || t("general.labels.na")}} + description={`${item.ownr_fn || ""} ${item.ownr_ln || ""} ${ + item.ownr_co_nm || "" + } - ${item.v_model_yr || ""} ${item.v_make_desc || ""} ${ + item.v_model_desc || "" + }`} + right={({ style }) => ( + + )} + /> ); } diff --git a/components/media-cache-overlay/media-cache-overlay.component.jsx b/components/media-cache-overlay/media-cache-overlay.component.jsx index 591f208..f160a73 100644 --- a/components/media-cache-overlay/media-cache-overlay.component.jsx +++ b/components/media-cache-overlay/media-cache-overlay.component.jsx @@ -1,7 +1,7 @@ +import { Ionicons } from "@expo/vector-icons"; import React from "react"; -import { Modal } from "react-native"; +import { Modal, SafeAreaView, TouchableOpacity, View } from "react-native"; import Gallery from "react-native-image-gallery"; - export default function MediaCacheOverlay({ photos, previewVisible, @@ -9,7 +9,6 @@ export default function MediaCacheOverlay({ imgIndex, setImgIndex, }) { - console.log("photos :>> ", photos); return ( setPreviewVisible(false)} @@ -17,7 +16,20 @@ export default function MediaCacheOverlay({ visible={previewVisible} transparent={false} > - + + + setPreviewVisible(false)} + > + + + ); } diff --git a/components/screen-media-browser/screen-media-browser.component.jsx b/components/screen-media-browser/screen-media-browser.component.jsx index 647a450..97d4771 100644 --- a/components/screen-media-browser/screen-media-browser.component.jsx +++ b/components/screen-media-browser/screen-media-browser.component.jsx @@ -2,7 +2,6 @@ import { Ionicons } from "@expo/vector-icons"; import { AssetsSelector } from "expo-images-picker"; import * as MediaLibrary from "expo-media-library"; import _ from "lodash"; -import plimit from "p-limit"; import React, { useCallback, useState } from "react"; import { useTranslation } from "react-i18next"; import { StyleSheet, Text, View } from "react-native"; @@ -22,7 +21,7 @@ import CameraSelectJob from "../camera-select-job/camera-select-job.component"; import UploadDeleteSwitch from "../upload-delete-switch/upload-delete-switch.component"; import UploadProgress from "../upload-progress/upload-progress.component"; -const limit = plimit(2); +//const limit = plimit(2); const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -52,50 +51,49 @@ export function ImageBrowserScreen({ async function handleOnSuccess(uri, id) { console.log("Succesful upload!", uri); logImEXEvent("imexmobile_successful_upload"); - if (deleteAfterUpload) { - try { - const result = await MediaLibrary.deleteAssetsAsync([id]); - console.log("Delete result :>> ", result); - } catch (error) { - console.log("Unable to delete picture.", error); - } - } setUploads((prevUploads) => _.omit(prevUploads, uri)); } const onDone = async (data) => { logImEXEvent("imexmobile_upload_documents", { count: data.length }); - const actions = []; - data.forEach(function (p) { - let filename; - //Appears to work for android. - //iOS provides the filename, android doe snot. - filename = p.filename || p.uri.split("/").pop(); - actions.push( - limit( - handleUpload( - { - //iOS provides the file name. Android does not. - uri: p.uri, - filename, - onError: handleOnError, - onProgress: ({ percent }) => handleOnProgress(filename, percent), - onSuccess: () => handleOnSuccess(filename, p.id), - }, - { - bodyshop: bodyshop, - jobId: - selectedCameraJobId !== "temp" ? selectedCameraJobId : null, - uploaded_by: currentUser.email, - photo: p, - } - ) - ) - ); - }); - await Promise.all(actions); + const ret = await Promise.all( + data.map(async (p) => { + let filename; + //Appears to work for android. + //iOS provides the filename, android doe snot. + 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, + onProgress: ({ percent }) => handleOnProgress(filename, percent), + onSuccess: () => handleOnSuccess(filename, p.id), + }, + { + bodyshop: bodyshop, + jobId: selectedCameraJobId !== "temp" ? selectedCameraJobId : null, + uploaded_by: currentUser.email, + photo: p, + } + ); + return result; + }) + ); + + if (deleteAfterUpload) { + try { + const result = await MediaLibrary.deleteAssetsAsync( + ret.map((r) => r.mediaId) + ); + console.log("Delete result :>> ", result); + } catch (error) { + console.log("Unable to delete picture.", error); + } + } forceRerender(); - //navigation.goBack(); }; return ( diff --git a/components/upload-progress/upload-progress.component.jsx b/components/upload-progress/upload-progress.component.jsx index f0396e6..cf0e9f2 100644 --- a/components/upload-progress/upload-progress.component.jsx +++ b/components/upload-progress/upload-progress.component.jsx @@ -1,4 +1,5 @@ import { Ionicons } from "@expo/vector-icons"; +import _ from "lodash"; import React, { useMemo } from "react"; import { ScrollView, @@ -8,7 +9,6 @@ import { View, } from "react-native"; import * as Progress from "react-native-progress"; -import _ from "lodash"; export default function UploadProgress({ uploads, setUploads }) { const uploadKeys = useMemo(() => { if (uploads) return Object.keys(uploads); @@ -46,7 +46,6 @@ export default function UploadProgress({ uploads, setUploads }) { const styles = StyleSheet.create({ container: { display: "flex", - //flex: 1, }, progressItem: { display: "flex", diff --git a/graphql/client.js b/graphql/client.js index 6f96724..523630b 100644 --- a/graphql/client.js +++ b/graphql/client.js @@ -1,19 +1,17 @@ //GQL Imports import { ApolloClient, + from, + HttpLink, InMemoryCache, split, - ApolloLink, - HttpLink, - from, } from "@apollo/client"; import { setContext } from "@apollo/client/link/context"; +import { onError } from "@apollo/client/link/error"; import { RetryLink } from "@apollo/client/link/retry"; import { WebSocketLink } from "@apollo/client/link/ws"; -import { SubscriptionClient } from "subscriptions-transport-ws"; -import { auth } from "../firebase/firebase.utils"; -import { onError } from "@apollo/client/link/error"; import { getMainDefinition } from "@apollo/client/utilities"; +import { auth } from "../firebase/firebase.utils"; const httpLink = new HttpLink({ // uri: "https://bodyshop-dev-db.herokuapp.com/v1/graphql", @@ -53,7 +51,6 @@ const errorLink = onError( ); if (networkError) console.error(`[Network error]: ${JSON.stringify(networkError)}`); - console.log(operation.getContext()); } ); diff --git a/package-lock.json b/package-lock.json index 497b8f1..d53e518 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz", "react-native-easy-grid": "^0.2.2", "react-native-gesture-handler": "~1.8.0", - "react-native-image-gallery": "^2.1.5", + "react-native-image-gallery": "meliorence/react-native-image-gallery#pull/152/head", "react-native-indicators": "^0.17.0", "react-native-pager-view": "^5.1.0", "react-native-paper": "^4.7.2", @@ -13074,8 +13074,8 @@ }, "node_modules/react-native-image-gallery": { "version": "2.1.5", - "resolved": "https://registry.npmjs.org/react-native-image-gallery/-/react-native-image-gallery-2.1.5.tgz", - "integrity": "sha512-xC7nuPu4GUH0da6byofQ10LjtqlKj+VaLc0NHBJmeMHVvdvmRvFEO6UOq0Q0m/ePx3OQiPTNwGbf5BSPJEKa0w==", + "resolved": "git+ssh://git@github.com/meliorence/react-native-image-gallery.git#06c9564e0f9978b1ed20306c8b1c7131620dcdeb", + "license": "ISC", "dependencies": { "prop-types": "^15.6.0", "react-mixin": "^3.0.5", @@ -25332,9 +25332,8 @@ } }, "react-native-image-gallery": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/react-native-image-gallery/-/react-native-image-gallery-2.1.5.tgz", - "integrity": "sha512-xC7nuPu4GUH0da6byofQ10LjtqlKj+VaLc0NHBJmeMHVvdvmRvFEO6UOq0Q0m/ePx3OQiPTNwGbf5BSPJEKa0w==", + "version": "git+ssh://git@github.com/meliorence/react-native-image-gallery.git#06c9564e0f9978b1ed20306c8b1c7131620dcdeb", + "from": "react-native-image-gallery@meliorence/react-native-image-gallery#pull/152/head", "requires": { "prop-types": "^15.6.0", "react-mixin": "^3.0.5", diff --git a/package.json b/package.json index c01b264..3b1c657 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz", "react-native-easy-grid": "^0.2.2", "react-native-gesture-handler": "~1.8.0", - "react-native-image-gallery": "^2.1.5", + "react-native-image-gallery": "meliorence/react-native-image-gallery#pull/152/head", "react-native-indicators": "^0.17.0", "react-native-pager-view": "^5.1.0", "react-native-paper": "^4.7.2", diff --git a/util/document-upload.utility.js b/util/document-upload.utility.js index 9512253..ccbb33c 100644 --- a/util/document-upload.utility.js +++ b/util/document-upload.utility.js @@ -10,7 +10,7 @@ var cleanAxios = axios.create(); cleanAxios.interceptors.request.eject(axiosAuthInterceptorId); export const handleUpload = async (ev, context) => { - const { uri, filename, onError, onSuccess, onProgress } = ev; + const { uri, filename, mediaId, onError, onSuccess, onProgress } = ev; const { bodyshop, jobId } = context; const newFile = await (await fetch(uri)).blob(); @@ -20,8 +20,9 @@ export const handleUpload = async (ev, context) => { /\.[^/.]+$/, "" )}`; - return uploadToCloudinary( + const res = await uploadToCloudinary( key, + mediaId, extension, newFile.type, newFile, @@ -30,10 +31,12 @@ export const handleUpload = async (ev, context) => { onProgress, context ); + return res; }; export const uploadToCloudinary = async ( key, + mediaId, extension, fileType, file, @@ -175,9 +178,13 @@ export const uploadToCloudinary = async ( // message: JSON.stringify(JSON.stringify(documentInsert.errors)), // }), // }); - return { success: false, error: JSON.stringify(documentInsert.errors) }; + return { + success: false, + error: JSON.stringify(documentInsert.errors), + mediaId, + }; } - return { success: true }; + return { success: true, mediaId }; }; export function DetermineFileType(filetype) { diff --git a/yarn.lock b/yarn.lock index 26f8d30..9358f43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7363,9 +7363,8 @@ "invariant" "^2.2.4" "prop-types" "^15.7.2" -"react-native-image-gallery@^2.1.5": - "integrity" "sha512-xC7nuPu4GUH0da6byofQ10LjtqlKj+VaLc0NHBJmeMHVvdvmRvFEO6UOq0Q0m/ePx3OQiPTNwGbf5BSPJEKa0w==" - "resolved" "https://registry.npmjs.org/react-native-image-gallery/-/react-native-image-gallery-2.1.5.tgz" +"react-native-image-gallery@meliorence/react-native-image-gallery#pull/152/head": + "resolved" "git+ssh://git@github.com/meliorence/react-native-image-gallery.git#06c9564e0f9978b1ed20306c8b1c7131620dcdeb" "version" "2.1.5" dependencies: "prop-types" "^15.6.0"