Resolve issue for temp uploads & add search.

This commit is contained in:
Patrick Fic
2021-05-13 09:39:29 -07:00
parent bdf7390678
commit b6155c6a85
11 changed files with 230 additions and 185 deletions

View File

@@ -49,6 +49,7 @@ export function ImageBrowserScreen({
const forceRerender = useCallback(() => {
setTick((tick) => tick + 1);
}, []);
const client = useApolloClient();
async function handleOnSuccess(uri, id) {
console.log("Succesful upload!", uri);
@@ -61,44 +62,45 @@ export function ImageBrowserScreen({
//Validate to make sure the totals for the file sizes do not exceed the total on the job.
const queryData = await client.query({
query: GET_DOC_SIZE_TOTALS,
if (selectedCameraJobId !== "temp") {
const queryData = await client.query({
query: GET_DOC_SIZE_TOTALS,
fetchPolicy: "network-only",
variables: {
jobId: selectedCameraJobId !== "temp" ? selectedCameraJobId : null,
},
});
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("data :>> ", data);
console.log(
"Size of uploaded documents.",
queryData.data.documents_aggregate.aggregate.sum.size,
"Shop Limit",
bodyshop.jobsizelimit,
"Space remaining",
bodyshop.jobsizelimit -
fetchPolicy: "network-only",
variables: {
jobId: selectedCameraJobId,
},
});
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("data :>> ", data);
console.log(
"Size of uploaded documents.",
queryData.data.documents_aggregate.aggregate.sum.size,
"Total of uploaded files",
totalOfUploads
);
if (
bodyshop.jobsizelimit -
queryData.data.documents_aggregate.aggregate.sum.size <=
totalOfUploads
) {
//No more room... abandon ship.
Alert.alert(
t("mediabrowser.labels.storageexceeded_title"),
t("mediabrowser.labels.storageexceeded")
"Shop Limit",
bodyshop.jobsizelimit,
"Space remaining",
bodyshop.jobsizelimit -
queryData.data.documents_aggregate.aggregate.sum.size,
"Total of uploaded files",
totalOfUploads
);
return;
if (
bodyshop.jobsizelimit -
queryData.data.documents_aggregate.aggregate.sum.size <=
totalOfUploads
) {
//No more room... abandon ship.
Alert.alert(
t("mediabrowser.labels.storageexceeded_title"),
t("mediabrowser.labels.storageexceeded")
);
return;
}
}
const ret = await Promise.all(