pass only needed collections to uploadManager

This commit is contained in:
Abhinav 2022-04-04 11:27:19 +05:30
parent e4170740e1
commit a043ef7d6e
2 changed files with 4 additions and 9 deletions

View file

@ -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);

View file

@ -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])
);