mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-10-18 23:07:27 +02:00
On Android, cancel() called destroy() first, and destroy() sets
savedInvoke to null, so the savedInvoke?.reject("cancelled") that
follows was a no-op. The pending scan() promise was never settled and
callers awaiting it were stranded, which is especially bad in windowed
mode where the page background stays transparent.
Reject the pending invoke before tearing the camera down, matching the
order the iOS implementation already uses.
This commit is contained in:
1 parent
de501ac3b0
commit
b3e52ce036
2 files changed
+9
-1
No files matched your search
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"barcode-scanner": patch
|
||||
"barcode-scanner-js": patch
|
||||
---
|
||||
|
||||
Fix `cancel()` on Android leaving the pending `scan()` promise unsettled: `destroy()` cleared the saved invoke before it was rejected, so the `"cancelled"` rejection never reached the caller. The pending scan is now rejected before the camera is torn down, matching iOS.
|
||||
@@ -332,8 +332,10 @@ class BarcodeScannerPlugin(private val activity: Activity) : Plugin(activity),
|
||||
|
||||
@Command
|
||||
fun cancel(invoke: Invoke) {
|
||||
destroy()
|
||||
// Reject the pending scan before destroy() clears savedInvoke, otherwise the
|
||||
// scan() promise is never settled. Mirrors the iOS implementation.
|
||||
savedInvoke?.reject("cancelled")
|
||||
destroy()
|
||||
invoke.resolve()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user