From c36027777e658bc73d5ba5ea57897c852beac373 Mon Sep 17 00:00:00 2001 From: siiky Date: Thu, 19 Sep 2024 14:39:08 +0100 Subject: [PATCH 1/3] fix: skip first few frames while camera is opening --- lib/brain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/brain.js b/lib/brain.js index cebadd81c..0bc966671 100644 --- a/lib/brain.js +++ b/lib/brain.js @@ -841,7 +841,7 @@ const readFailedFrames = callback => failedScansTmpdirs => _.flatten, failedScans => _.chunk(_.round(_.size(failedScans)/6), failedScans), _.map(failedScanGroup => - fsPromises.readFile(failedScanGroup[0]) + fsPromises.readFile(_.last(failedScanGroup)) .then(callback) .catch(console.error) ) From 11d76d661d2da9e9eddd866d3bfa224a27cb1741 Mon Sep 17 00:00:00 2001 From: siiky Date: Thu, 19 Sep 2024 14:56:32 +0100 Subject: [PATCH 2/3] refactor: unindent one level --- lib/brain.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/brain.js b/lib/brain.js index 0bc966671..1df358845 100644 --- a/lib/brain.js +++ b/lib/brain.js @@ -856,15 +856,13 @@ Brain.prototype.scanPDF = function scanPDF () { this.scanner.scanPDF417((err, result) => { this.scanBayLightOff() this.startDisabled = false - if (!this.isGenmegaMachine) { - if (err || !result) { - const photos = idCardData.getIdDataPhotos() - this.trader.updateIdCardPhotos(customer.id, { photos }) - .then(() => console.log('Successfully saved ', photos.length, ' id data photos')) - .catch(err => { - console.log('Error saving id card photos', err) - }) - } + if (!this.isGenmegaMachine && (err || !result)) { + const photos = idCardData.getIdDataPhotos() + this.trader.updateIdCardPhotos(customer.id, { photos }) + .then( + () => console.log('Successfully saved', photos.length, 'id data photos'), + err => console.log('Error saving id card photos', err) + ) } if (err) { From e7b5bbaed948e70964d9a000f5aba62a49087449 Mon Sep 17 00:00:00 2001 From: siiky Date: Thu, 19 Sep 2024 15:32:34 +0100 Subject: [PATCH 3/3] fix: treat no PDF417 result as error Otherwise the machine stays in the scanning screen until timeout. --- lib/brain.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/brain.js b/lib/brain.js index 1df358845..cb6a271b2 100644 --- a/lib/brain.js +++ b/lib/brain.js @@ -865,16 +865,11 @@ Brain.prototype.scanPDF = function scanPDF () { ) } - if (err) { - console.log(err) + if (err || !result) { + console.log(err || 'No PDF417 result') return idCardData.dispatch('SCAN_ERROR') } - if (!result) { - console.log('No PDF417 result') - return - } - if (this.hasExpired(result)) { console.log('Expired ID card') return idCardData.dispatch('SCAN_ERROR')