[PR #6687] [MERGED] [PM-23560] bug: Added guard to ensure duplicate scan events are not fired #19540

Closed
opened 2026-04-15 03:53:32 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/6687
Author: @aj-rosado
Created: 3/18/2026
Status: Merged
Merged: 3/20/2026
Merged by: @aj-rosado

Base: mainHead: PM-29829/duplicate-items-created-scanning-qrcode


📝 Commits (7)

  • 0be57fb Added guard to ensure duplicate scan events are not fired
  • 9ef718c Added BackgroundEvent to NavigateBack
  • cdaea62 Fixed tests
  • 5d5909b resetting hasHandledScan when error dialog is dismissed
  • d0f29bd Swapped BackgroundEvent to use DeferredBackgroundEvent on QrCodeScanViewModel
  • 7cb500a Added hasHandledScan to State
  • cf9bcb6 removed unnecessary code from tests

📊 Changes

5 files changed (+156 additions, -18 deletions)

View changed files

📝 app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModel.kt (+27 -3)
📝 app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModelTest.kt (+30 -1)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/qrcodescan/QrCodeScanViewModel.kt (+23 -4)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/qrcodescan/QrCodeScanScreenTest.kt (+1 -0)
📝 authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/qrcodescan/QrCodeScanViewModelTest.kt (+75 -10)

📄 Description

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-23560

📔 Objective

When scanning QR code totp items, multiples are being added, this is caused by QrCodeAnalyzer firing onQrCodeScanned every time it gets a result.
In order to avoid adding multiple items, a check on ViewModel was added in order to only allow the first result to be returned.
On some cases, if the image is analyzed right after opening the screen, the EventsEffect have not been initiated and the user is not being returned to be previous screen. To workaround that scenario, when the code has been scanned, we do not emit the code again but fire a NavigateBack event.

Same scenario was happening on PasswordManager, despite not creating multiple items, multiple events were fired.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/6687 **Author:** [@aj-rosado](https://github.com/aj-rosado) **Created:** 3/18/2026 **Status:** ✅ Merged **Merged:** 3/20/2026 **Merged by:** [@aj-rosado](https://github.com/aj-rosado) **Base:** `main` ← **Head:** `PM-29829/duplicate-items-created-scanning-qrcode` --- ### 📝 Commits (7) - [`0be57fb`](https://github.com/bitwarden/android/commit/0be57fb511d0c2d964a1ce0ad7860063041dbcc6) Added guard to ensure duplicate scan events are not fired - [`9ef718c`](https://github.com/bitwarden/android/commit/9ef718ca75656a87be6dfed0a6aebb79f3891a95) Added BackgroundEvent to NavigateBack - [`cdaea62`](https://github.com/bitwarden/android/commit/cdaea625cc6c1a5a03198e0d5020305ca61269a9) Fixed tests - [`5d5909b`](https://github.com/bitwarden/android/commit/5d5909bf9cd5ca242e68302d134c59716d7097b3) resetting hasHandledScan when error dialog is dismissed - [`d0f29bd`](https://github.com/bitwarden/android/commit/d0f29bdabc7f5a545b62795a0fc73fbf7851062b) Swapped BackgroundEvent to use DeferredBackgroundEvent on QrCodeScanViewModel - [`7cb500a`](https://github.com/bitwarden/android/commit/7cb500a0c9ddaf88e79646a7777f2543ee42be79) Added hasHandledScan to State - [`cf9bcb6`](https://github.com/bitwarden/android/commit/cf9bcb6e46e0e0f7b07cd988d9e659abe3bc0e8d) removed unnecessary code from tests ### 📊 Changes **5 files changed** (+156 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModel.kt` (+27 -3) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModelTest.kt` (+30 -1) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/qrcodescan/QrCodeScanViewModel.kt` (+23 -4) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/qrcodescan/QrCodeScanScreenTest.kt` (+1 -0) 📝 `authenticator/src/test/kotlin/com/bitwarden/authenticator/ui/authenticator/feature/qrcodescan/QrCodeScanViewModelTest.kt` (+75 -10) </details> ### 📄 Description ## 🎟️ Tracking https://bitwarden.atlassian.net/browse/PM-23560 ## 📔 Objective When scanning QR code totp items, multiples are being added, this is caused by `QrCodeAnalyzer` firing `onQrCodeScanned` every time it gets a result. In order to avoid adding multiple items, a check on ViewModel was added in order to only allow the first result to be returned. On some cases, if the image is analyzed right after opening the screen, the `EventsEffect` have not been initiated and the user is not being returned to be previous screen. To workaround that scenario, when the code has been scanned, we do not emit the code again but fire a NavigateBack event. Same scenario was happening on PasswordManager, despite not creating multiple items, multiple events were fired. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 03:53:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#19540