diff --git a/app/lib/pdf/barcodeDecoder.ts b/app/lib/pdf/barcodeDecoder.ts index a8c17c3..401f871 100644 --- a/app/lib/pdf/barcodeDecoder.ts +++ b/app/lib/pdf/barcodeDecoder.ts @@ -330,7 +330,7 @@ const copyBarcodeImage = (canvas:HTMLCanvasElement, decoderResult:Result):string } /** Finds PDF417 code within a file and decodes it */ -const decodeFromFile = async (file:File) => { +const decodeFromFile = async (file:File): Promise => { switch(file.type) { case 'image/png': case 'image/jpeg': @@ -341,13 +341,13 @@ const decodeFromFile = async (file:File) => { // if there are multiple pages, we will decode each page separately // and return the results from all pages const results = (await Promise.all(pageCanvas.map(async (canvas) => { - await yieldToBrowser('decodeFromCanvas'); - return await decodeFromCanvas(canvas); - }))) + await yieldToBrowser('decodeFromCanvas'); + return await decodeFromCanvas(canvas); + }))) // remove null results (pages with no PDF417 codes) .filter((result) => result !== null) // flatten the array of arrays into a single array - .flat(); + .flat() as DecodeResult[]; return(results); default: diff --git a/app/ui/BillEditForm.tsx b/app/ui/BillEditForm.tsx index 9d07238..9f605e5 100644 --- a/app/ui/BillEditForm.tsx +++ b/app/ui/BillEditForm.tsx @@ -60,6 +60,7 @@ export const BillEditForm:FC = ({ location, bill }) => { setBarcodeResults(null); const results = await findDecodePdf417(event); + if(results && results.length > 0) { if(results.length === 1) {