Resolve issue for temp uploads & add search.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user