Skip to content

Commit

Permalink
feat: consistent paths (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
JNdhlovu committed Aug 27, 2024
1 parent 5cabe1a commit c9a0133
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Sources/SmileID/Classes/SelfieCapture/SelfieViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ public class SelfieViewModel: ObservableObject, ARKitSmileDelegate {
smartSelfieLivenessImages.append(contentsOf: livenessImageInfos.compactMap { $0 })
}
guard let smartSelfieImage = smartSelfieImage,
smartSelfieLivenessImages.count == numLivenessImages else {
smartSelfieLivenessImages.count == numLivenessImages
else {
throw SmileIDError.unknown("Selfie capture failed")
}
let response = if isEnroll {
Expand Down Expand Up @@ -433,13 +434,19 @@ public class SelfieViewModel: ObservableObject, ARKitSmileDelegate {
}

func onFinished(callback: SmartSelfieResultDelegate) {
if let selfieImage, livenessImages.count == numLivenessImages {
if let selfieImage = selfieImage,
let selfiePath = getRelativePath(from: selfieImage),
livenessImages.count == numLivenessImages,
!livenessImages.contains(where: { getRelativePath(from: $0) == nil })
{
let livenessImagesPaths = livenessImages.compactMap { getRelativePath(from: $0) }

callback.didSucceed(
selfieImage: selfieImage,
livenessImages: livenessImages,
selfieImage: selfiePath,
livenessImages: livenessImagesPaths,
apiResponse: apiResponse
)
} else if let error {
} else if let error = error {
callback.didError(error: error)
} else {
callback.didError(error: SmileIDError.unknown("Unknown error"))
Expand Down

0 comments on commit c9a0133

Please sign in to comment.