Reduce use of uiservice
This commit is contained in:
parent
0ca4b06872
commit
6b55f3b2f1
2 changed files with 8 additions and 5 deletions
|
@ -6,6 +6,7 @@ import { getDedicatedCryptoWorker } from "@ente/shared/crypto";
|
|||
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
|
||||
import { CustomError } from "@ente/shared/error";
|
||||
import { Events, eventBus } from "@ente/shared/events";
|
||||
import { wait } from "@ente/shared/utils";
|
||||
import { Remote } from "comlink";
|
||||
import { UPLOAD_RESULT, UPLOAD_STAGES } from "constants/upload";
|
||||
import isElectron from "is-electron";
|
||||
|
@ -372,6 +373,10 @@ class UploadManager {
|
|||
const { collectionID } = fileWithCollection;
|
||||
const collection = this.collections.get(collectionID);
|
||||
fileWithCollection = { ...fileWithCollection, collection };
|
||||
|
||||
UIService.setFileProgress(fileWithCollection.localID, 0);
|
||||
await wait(0);
|
||||
|
||||
const { fileUploadResult, uploadedFile } = await uploader(
|
||||
worker,
|
||||
this.existingFiles,
|
||||
|
|
|
@ -242,21 +242,19 @@ interface UploadResponse {
|
|||
uploadedFile?: EnteFile;
|
||||
}
|
||||
|
||||
export async function uploader(
|
||||
export const uploader = async (
|
||||
worker: Remote<DedicatedCryptoWorker>,
|
||||
existingFiles: EnteFile[],
|
||||
fileWithCollection: FileWithCollection2,
|
||||
parsedMetadataJSONMap: ParsedMetadataJSONMap,
|
||||
uploaderName: string,
|
||||
): Promise<UploadResponse> {
|
||||
): Promise<UploadResponse> => {
|
||||
const name = assetName(fileWithCollection);
|
||||
log.info(`Uploading ${name}`);
|
||||
|
||||
const { collection, localID, ...uploadAsset2 } = fileWithCollection;
|
||||
/* TODO(MR): ElectronFile changes */
|
||||
const uploadAsset = uploadAsset2 as UploadAsset;
|
||||
UIService.setFileProgress(localID, 0);
|
||||
await wait(0);
|
||||
let fileTypeInfo: FileTypeInfo;
|
||||
let fileSize: number;
|
||||
try {
|
||||
|
@ -396,7 +394,7 @@ export async function uploader(
|
|||
return { fileUploadResult: UPLOAD_RESULT.FAILED };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const getFileName = (file: File | ElectronFile | string) =>
|
||||
typeof file == "string" ? basename(file) : file.name;
|
||||
|
|
Loading…
Add table
Reference in a new issue