mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-22 23:45:02 +00:00
Fixed dynamic operator loading not finishing for some operators.
This commit is contained in:
parent
efd4bdc493
commit
b1bb8e0f02
@ -15,7 +15,7 @@ function Dynamic() {
|
|||||||
const operators = listOperatorNames();
|
const operators = listOperatorNames();
|
||||||
const activeOperator = useRef<typeof Operator>();
|
const activeOperator = useRef<typeof Operator>();
|
||||||
|
|
||||||
function selectionChanged(s: BaseSyntheticEvent) {
|
async function selectionChanged(s: BaseSyntheticEvent) {
|
||||||
const selectedValue = s.target.value;
|
const selectedValue = s.target.value;
|
||||||
console.log("Selection changed to", selectedValue);
|
console.log("Selection changed to", selectedValue);
|
||||||
if(selectedValue == "none") {
|
if(selectedValue == "none") {
|
||||||
@ -23,9 +23,13 @@ function Dynamic() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
i18next.loadNamespaces(selectedValue, (err, t) => {
|
console.log("Loading namespaces for", selectedValue);
|
||||||
|
await i18next.loadNamespaces(selectedValue, (err, t) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
});
|
||||||
|
console.log("Loading namespaces done");
|
||||||
|
|
||||||
|
console.log("Loading modules for", selectedValue);
|
||||||
const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>;
|
const LoadingModule = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`) as Promise<{ [key: string]: typeof Operator }>;
|
||||||
LoadingModule.then((Module) => {
|
LoadingModule.then((Module) => {
|
||||||
const Operator = Module[capitalizeFirstLetter(selectedValue)];
|
const Operator = Module[capitalizeFirstLetter(selectedValue)];
|
||||||
@ -37,7 +41,6 @@ function Dynamic() {
|
|||||||
// This will update children
|
// This will update children
|
||||||
setSchemaDescription(description);
|
setSchemaDescription(description);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit(e: BaseSyntheticEvent) {
|
async function handleSubmit(e: BaseSyntheticEvent) {
|
||||||
@ -75,7 +78,7 @@ function Dynamic() {
|
|||||||
const validationResults = activeOperator.current.schema.validate({input: inputs, values: action.values});
|
const validationResults = activeOperator.current.schema.validate({input: inputs, values: action.values});
|
||||||
|
|
||||||
if(validationResults.error) {
|
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 {
|
else {
|
||||||
action.values = validationResults.value.values;
|
action.values = validationResults.value.values;
|
||||||
|
@ -8,7 +8,7 @@ export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- a
|
|||||||
else { // File(s)
|
else { // File(s)
|
||||||
const firstWrongFile = value.find(f => f.mimetype != "application/pdf")
|
const firstWrongFile = value.find(f => f.mimetype != "application/pdf")
|
||||||
if(firstWrongFile)
|
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);
|
return PdfFile.fromMulterFiles(value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user