Skip to content

Commit

Permalink
fix: not bound to a valid camera fix (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
JNdhlovu authored Apr 28, 2024
1 parent f471f8d commit 6c91907
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## Unreleased

* Fixed a bug where Document Capture would occasionally fail

## 10.1.0

* Added an Offline Mode, enabled by calling `SmileID.setAllowOfflineMode(true)`. If a job is attempted while the device is offline, and offline mode has been enabled, the UI will complete successfully and the job can be submitted at a later time by calling `SmileID.submitJob(jobId)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DocumentCaptureViewModel(
* taps the manual capture button.
*/
fun captureDocument(cameraState: CameraState) {
if (isCapturing) {
if (isCapturing || uiState.value.documentImageToConfirm != null) {
Timber.v("Already capturing. Skipping duplicate capture request")
return
}
Expand All @@ -132,7 +132,6 @@ class DocumentCaptureViewModel(
}
val documentFile = createDocumentFile(jobId, (side == DocumentCaptureSide.Front))
cameraState.takePicture(documentFile) { result ->
isCapturing = false
when (result) {
is ImageCaptureResult.Success -> {
_uiState.update {
Expand All @@ -153,6 +152,8 @@ class DocumentCaptureViewModel(
}
}
}
// NB: This should be set to false last after processing is done for the captured image
isCapturing = false
}
}

Expand Down Expand Up @@ -243,7 +244,9 @@ class DocumentCaptureViewModel(
)
}

if (captureNextAnalysisFrame && areEdgesDetected && !isCapturing && !isFocusing) {
if (captureNextAnalysisFrame && areEdgesDetected && !isCapturing && !isFocusing &&
uiState.value.documentImageToConfirm == null
) {
captureNextAnalysisFrame = false
captureDocument(cameraState)
}
Expand Down

0 comments on commit 6c91907

Please sign in to comment.