pass only needed collections to uploadManager
This commit is contained in:
parent
e4170740e1
commit
a043ef7d6e
|
@ -225,7 +225,7 @@ export default function Upload(props: Props) {
|
|||
return collectionWiseFiles;
|
||||
}
|
||||
|
||||
const uploadFilesToExistingCollection = async (collection) => {
|
||||
const uploadFilesToExistingCollection = async (collection: Collection) => {
|
||||
try {
|
||||
uploadInit();
|
||||
const filesWithCollectionToUpload: FileWithCollection[] =
|
||||
|
@ -234,7 +234,7 @@ export default function Upload(props: Props) {
|
|||
localID: index,
|
||||
collectionID: collection.id,
|
||||
}));
|
||||
await uploadFiles(filesWithCollectionToUpload);
|
||||
await uploadFiles(filesWithCollectionToUpload, [collection]);
|
||||
} catch (e) {
|
||||
logError(e, 'Failed to upload files to existing collections');
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ export default function Upload(props: Props) {
|
|||
|
||||
const uploadFiles = async (
|
||||
filesWithCollectionToUpload: FileWithCollection[],
|
||||
collections?: Collection[]
|
||||
collections: Collection[]
|
||||
) => {
|
||||
try {
|
||||
props.setUploadInProgress(true);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { getLocalFiles, setLocalFiles } from '../fileService';
|
||||
import { getLocalCollections } from '../collectionService';
|
||||
import { SetFiles } from 'types/gallery';
|
||||
import { getDedicatedCryptoWorker } from 'utils/crypto';
|
||||
import {
|
||||
|
@ -59,7 +58,7 @@ class UploadManager {
|
|||
this.setFiles = setFiles;
|
||||
}
|
||||
|
||||
private async init(newCollections?: Collection[]) {
|
||||
private async init(collections: Collection[]) {
|
||||
this.filesToBeUploaded = [];
|
||||
this.failedFiles = [];
|
||||
this.parsedMetadataJSONMap = new Map<string, ParsedMetadataJSON>();
|
||||
|
@ -71,10 +70,6 @@ class UploadManager {
|
|||
this.existingFilesCollectionWise = sortFilesIntoCollections(
|
||||
this.existingFiles
|
||||
);
|
||||
const collections = await getLocalCollections();
|
||||
if (newCollections) {
|
||||
collections.push(...newCollections);
|
||||
}
|
||||
this.collections = new Map(
|
||||
collections.map((collection) => [collection.id, collection])
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue