Skip to content

Commit

Permalink
attempt to fix #466 (data missing in onProcessed, compared to earlier…
Browse files Browse the repository at this point in the history
… versions of library), submitted from comments by @ghevge
  • Loading branch information
ericblade committed Oct 25, 2023
1 parent a384d9e commit c03e755
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/quagga/quagga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ export default class Quagga {
if (result && this.context.onUIThread) {
this.transformResult(result);
this.addResult(result, imageData);
resultToPublish = result.barcodes || result;
// @ts-ignore
resultToPublish = result?.barcodes?.length > 0 ? result.barcodes : result;
}

Events.publish('processed', resultToPublish as never);
Expand Down
8 changes: 6 additions & 2 deletions src/quagga/qworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ export function initWorker(config: QuaggaJSConfigObject, inputStream: any, cb: F
} else if (e.data.event === 'processed') {
workerThread.imageData = new Uint8Array(e.data.imageData);
workerThread.busy = false;
// TODO: how to thread publishResult into here?
// publishResult(e.data.result, workerThread.imageData);
// TODO: how to thread publishResult into here? TypeScript says it's not here. https://github.com/ericblade/quagga2/issues/466#issuecomment-1724248080 says it's necessary?
// @ts-ignore
if (typeof publishResult !== 'undefined') {
// @ts-ignore
publishResult(e.data.result, workerThread.imageData);
}
} else if (e.data.event === 'error') {
if (ENV.development) {
console.log('Worker error: ' + e.data.message);
Expand Down

0 comments on commit c03e755

Please sign in to comment.