diff --git a/client-tauri/src/pages/Dynamic.tsx b/client-tauri/src/pages/Dynamic.tsx index d5cdf5937..369ecd56a 100644 --- a/client-tauri/src/pages/Dynamic.tsx +++ b/client-tauri/src/pages/Dynamic.tsx @@ -15,7 +15,7 @@ function Dynamic() { const operators = listOperatorNames(); const activeOperator = useRef(); - function selectionChanged(s: BaseSyntheticEvent) { + async function selectionChanged(s: BaseSyntheticEvent) { const selectedValue = s.target.value; console.log("Selection changed to", selectedValue); if(selectedValue == "none") { @@ -23,20 +23,23 @@ function Dynamic() { return; } - i18next.loadNamespaces(selectedValue, (err, t) => { + console.log("Loading namespaces for", selectedValue); + await i18next.loadNamespaces(selectedValue, (err, t) => { if (err) throw err; + }); + console.log("Loading namespaces done"); - const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>; - LoadingModule.then((Module) => { - const Operator = Module[capitalizeFirstLetter(selectedValue)]; - const description = Operator.schema.describe(); - console.log(Operator.schema); - console.log(description); + console.log("Loading modules for", selectedValue); + const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>; + LoadingModule.then((Module) => { + const Operator = Module[capitalizeFirstLetter(selectedValue)]; + const description = Operator.schema.describe(); + console.log(Operator.schema); + console.log(description); - activeOperator.current = Operator; - // This will update children - setSchemaDescription(description); - }); + activeOperator.current = Operator; + // This will update children + setSchemaDescription(description); }); } @@ -75,7 +78,7 @@ function Dynamic() { const validationResults = activeOperator.current.schema.validate({input: inputs, values: action.values}); if(validationResults.error) { - console.log({error: "Validation failed", details: validationResults.error.message}); + console.error({error: "Validation failed", details: validationResults.error.message}, validationResults.error.stack); } else { action.values = validationResults.value.values; diff --git a/shared-operations/src/wrappers/PdfFileJoi.ts b/shared-operations/src/wrappers/PdfFileJoi.ts index 8dd9e703f..47376733f 100644 --- a/shared-operations/src/wrappers/PdfFileJoi.ts +++ b/shared-operations/src/wrappers/PdfFileJoi.ts @@ -8,7 +8,7 @@ export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- a else { // File(s) const firstWrongFile = value.find(f => f.mimetype != "application/pdf") if(firstWrongFile) - throw new Error(`at least one of the files provided doesn't seem to be a PDF. Got ${firstWrongFile.mimetype} instead.`); + throw new Error(`at least one of the files provided doesn't seem to be a PDF. Got the file ${JSON.stringify(firstWrongFile)} instead.`); return PdfFile.fromMulterFiles(value); }