Skip to content

Commit

Permalink
improve multi page handling
Browse files Browse the repository at this point in the history
  • Loading branch information
manuc66 committed May 20, 2022
1 parent fcae704 commit 2aa3c6e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,26 +265,26 @@ async function executeScanJob(

console.log("New job created:", jobUrl);

let currentPage: ScanPage | null = null;
let job = await HPApi.getJob(jobUrl);
while (job.jobState !== "Completed") {
job = await waitPrinterUntilItIsReadyToUploadOrCompleted(jobUrl);

if (job.jobState == "Completed") {
if (currentPage != null) {
scanJobContent.elements.push(currentPage);
}
continue;
}

if (job.jobState === "Processing") {
currentPage = await handleProcessingState(
const page = await handleProcessingState(
job,
inputSource,
folder,
scanCount,
scanJobContent.elements.length + 1
);
job = await HPApi.getJob(jobUrl);
if (page != null && job.jobState != "Canceled") {
scanJobContent.elements.push(page);
}
} else if (job.jobState === "Canceled") {
console.log("Job cancelled by device");
break;
Expand Down

0 comments on commit 2aa3c6e

Please sign in to comment.