From 3a64be15a7274eba47ad8eeb50526a19eeac8cd6 Mon Sep 17 00:00:00 2001 From: Daniel Fernando Rico Date: Thu, 5 Dec 2024 16:11:50 -0500 Subject: [PATCH] fix: add a generic message to android dialog when scan process fails --- .../io/twentysixty/rn/eidreader/EIdReaderModule.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/io/twentysixty/rn/eidreader/EIdReaderModule.kt b/android/src/main/java/io/twentysixty/rn/eidreader/EIdReaderModule.kt index 183a261..8aebc9e 100644 --- a/android/src/main/java/io/twentysixty/rn/eidreader/EIdReaderModule.kt +++ b/android/src/main/java/io/twentysixty/rn/eidreader/EIdReaderModule.kt @@ -198,7 +198,10 @@ class EIdReaderModule(reactContext: ReactApplicationContext) : } private fun reject(e: Exception) { - stopReading() + currentActivity?.runOnUiThread(Runnable { + _dialog?.setMessage("Sorry, there was a problem reading the passport. Please try again") + }) + stopReading(false) _promise?.reject(e) } @@ -255,11 +258,13 @@ class EIdReaderModule(reactContext: ReactApplicationContext) : } @ReactMethod - fun stopReading() { + fun stopReading(removeDialog: Boolean = true) { isReading = false mrzInfo = null - if (_dialog != null) _dialog?.dismiss() - _dialog = null + if (_dialog != null && removeDialog) { + _dialog?.dismiss() + _dialog = null + } } @ReactMethod