Show upload progress percent on queue rows during POST.
Share percentFromAxiosProgress for axios upload and ExifTool WASM download; update queue entries from upload helpers via queue key.
This commit is contained in:
@@ -4,6 +4,7 @@ import axios from 'axios';
|
||||
import { EXIFTOOL_WORKER_INIT_JPEG } from '@/consts/exiftoolWorkerInitJpeg';
|
||||
import type { ExiftoolWorkerInMessage } from '@/types/workers/exiftoolWorkerInMessage';
|
||||
import type { ExiftoolWorkerJob } from '@/types/workers/exiftoolWorkerJob';
|
||||
import { percentFromAxiosProgress } from '@/utils/percentFromAxiosProgress';
|
||||
import { resolveErrorMessage } from '@/utils/resolveErrorMessage';
|
||||
import { toArrayBuffer } from '@/utils/toArrayBuffer';
|
||||
|
||||
@@ -18,15 +19,13 @@ const fetchZeroperlWasm = async (): Promise<Response> => {
|
||||
const { data } = await axios.get<ArrayBuffer>(zeroperlWasmUrl, {
|
||||
responseType: 'arraybuffer',
|
||||
onDownloadProgress: progressEvent => {
|
||||
if (!progressEvent.total) {
|
||||
const percent = percentFromAxiosProgress(progressEvent);
|
||||
|
||||
if (percent === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const percent = Math.min(100, (progressEvent.loaded / progressEvent.total) * 100);
|
||||
|
||||
const rounded = parseFloat(percent.toFixed(2));
|
||||
|
||||
self.postMessage({ type: 'wasm-download-progress', percent: rounded });
|
||||
self.postMessage({ type: 'wasm-download-progress', percent });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user