From 5fc4f58c6902cc3e80dd868c17c947c99185409f Mon Sep 17 00:00:00 2001 From: Ueli Niederer Date: Wed, 26 May 2021 13:33:22 +0200 Subject: [PATCH 1/3] Correct wiring error handling wiring --- BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs | 8 ++++++++ .../wwwroot/BlazorBarcodeScanner.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs b/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs index f12651c..fe434f7 100644 --- a/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs +++ b/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs @@ -28,6 +28,14 @@ public static void ReceiveBarcode(string barcodeText) BarcodeReaderInterop.OnBarcodeReceived(barcodeText); } + [JSInvokable] + public static void ReceiveError(object error) + { + // What to do with the knowledge that an error happened? + // Looking at current examples this might indicate issues with one of the decoders + // (namely BrowserQRCodeReader appears to throw errors occassionally...) + } + [JSInvokable] public static void ReceiveNotFound() { diff --git a/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js b/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js index a287b66..a415669 100644 --- a/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js +++ b/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js @@ -107,7 +107,7 @@ window.BlazorBarcodeScanner = { } if (err && !(err instanceof ZXing.NotFoundException)) { console.error(err); - DotNet.invokeMethodAsync('BlazorBarcodeScanner.ZXing.JS', 'ReceiveBarcode', err) + DotNet.invokeMethodAsync('BlazorBarcodeScanner.ZXing.JS', 'ReceiveError', err) .then(message => { console.log(message); }); From ea896882abbd44d5f45cd155f1b8dda3fca3a43a Mon Sep 17 00:00:00 2001 From: Ueli Niederer Date: Wed, 26 May 2021 13:42:58 +0200 Subject: [PATCH 2/3] Remove debug outputs --- BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js b/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js index a415669..5646179 100644 --- a/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js +++ b/BlazorBarcodeScanner.ZXing.JS/wwwroot/BlazorBarcodeScanner.js @@ -96,7 +96,6 @@ window.BlazorBarcodeScanner = { console.log("Starting decoding with " + videoConstraints); await this.codeReader.decodeFromConstraints({ video: videoConstraints }, video, (result, err) => { if (result) { - console.log(result); if (this.lastPictureDecodedFormat) { this.lastPictureDecoded = this.codeReader.captureCanvas.toDataURL(this.lastPictureDecodedFormat); } @@ -106,7 +105,6 @@ window.BlazorBarcodeScanner = { }); } if (err && !(err instanceof ZXing.NotFoundException)) { - console.error(err); DotNet.invokeMethodAsync('BlazorBarcodeScanner.ZXing.JS', 'ReceiveError', err) .then(message => { console.log(message); From 109856a28a834ade43228785117ed49e85c31550 Mon Sep 17 00:00:00 2001 From: Ueli Niederer Date: Wed, 26 May 2021 13:56:28 +0200 Subject: [PATCH 3/3] Corrected typo There was a typo in a comment. --- BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs b/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs index fe434f7..cac09d4 100644 --- a/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs +++ b/BlazorBarcodeScanner.ZXing.JS/JsInteropClass.cs @@ -33,7 +33,7 @@ public static void ReceiveError(object error) { // What to do with the knowledge that an error happened? // Looking at current examples this might indicate issues with one of the decoders - // (namely BrowserQRCodeReader appears to throw errors occassionally...) + // (namely BrowserQRCodeReader appears to throw errors occasionally...) } [JSInvokable]