/api/download
This commit is contained in:
@@ -274,9 +274,39 @@ const useDocumentMutations = ({
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(
|
||||
documentIds.map((documentId) => api.post(`/documents/${documentId}/trash`)),
|
||||
);
|
||||
const softDeleteTargets = [];
|
||||
const hardDeleteTargets = [];
|
||||
|
||||
documentIds.forEach((documentId) => {
|
||||
const lookupDoc =
|
||||
documentLookup && typeof documentLookup.get === 'function'
|
||||
? documentLookup.get(documentId)
|
||||
: documentLookup?.[documentId];
|
||||
|
||||
if (lookupDoc && lookupDoc.deleted_at) {
|
||||
hardDeleteTargets.push(documentId);
|
||||
} else {
|
||||
softDeleteTargets.push(documentId);
|
||||
}
|
||||
});
|
||||
|
||||
const operations = [];
|
||||
if (softDeleteTargets.length) {
|
||||
operations.push(
|
||||
Promise.all(
|
||||
softDeleteTargets.map((documentId) => api.post(`/documents/${documentId}/trash`)),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (hardDeleteTargets.length) {
|
||||
operations.push(
|
||||
Promise.all(
|
||||
hardDeleteTargets.map((documentId) => api.delete(`/documents/${documentId}`)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all(operations);
|
||||
|
||||
removeDocumentsFromCaches(documentIds);
|
||||
|
||||
@@ -302,6 +332,7 @@ const useDocumentMutations = ({
|
||||
[
|
||||
api,
|
||||
token,
|
||||
documentLookup,
|
||||
removeDocumentsFromCaches,
|
||||
previewDocumentId,
|
||||
closeDocumentPreview,
|
||||
|
||||
Reference in New Issue
Block a user