single OCR thread in //

This commit is contained in:
Loïc Gremaud 2025-11-23 12:20:59 +01:00
parent 012b72527b
commit 8f88548a59
Signed by: Legrems
GPG Key ID: D4620E6DF3E0121D

View File

@ -248,6 +248,8 @@ const isDragOver = ref(false);
const error = ref("");
const files = ref<SubmissionFile[]>([]);
const isProcessingOCR = ref(false);
// Watch for external changes to modelValue
watch(
() => props.modelValue,
@ -374,6 +376,12 @@ const isOpusMagnumImage = (file: File): boolean => {
};
const processOCR = async (submissionFile: SubmissionFile) => {
while (isProcessingOCR.value) {
console.log("OCR is already processing, waiting 500ms...");
await new Promise((res) => setTimeout(res, 500));
}
isProcessingOCR.value = true;
// Find the file in the reactive array to ensure proper reactivity
const fileIndex = files.value.findIndex(
(f) => f.file === submissionFile.file,
@ -412,6 +420,7 @@ const processOCR = async (submissionFile: SubmissionFile) => {
} finally {
files.value[fileIndex].ocrProcessing = false;
}
isProcessingOCR.value = false;
};
const retryOCR = (submissionFile: SubmissionFile) => {