Skip to content

Commit

Permalink
fix: handle error on loading view (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisabhash committed Aug 22, 2024
1 parent 1705d97 commit cb5f4fd
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public struct FaceLivenessDetectorView: View {
isPreviewScreenEnabled: !disableStartView
)
)

faceDetector.setFaceDetectionSessionConfigurationWrapper(configuration: viewModel)
}

init(
Expand Down Expand Up @@ -142,6 +140,23 @@ public struct FaceLivenessDetectorView: View {
} catch {
throw FaceLivenessDetectionError.accessDenied
}

DispatchQueue.main.async {
if let faceDetector = viewModel.faceDetector as? FaceDetectorShortRange.Model {
faceDetector.setFaceDetectionSessionConfigurationWrapper(configuration: viewModel)
}
}
}
}
.onReceive(viewModel.$livenessState) { output in
switch output.state {
case .encounteredUnrecoverableError(let error):
let closeCode = error.webSocketCloseCode ?? .normalClosure
viewModel.livenessService?.closeSocket(with: closeCode)
isPresented = false
onCompletion(.failure(mapError(error)))
default:
break
}
}
case .awaitingLivenessSession(let challenge):
Expand Down

0 comments on commit cb5f4fd

Please sign in to comment.