Skip to content
Snippets Groups Projects
Commit 9362468a authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Merge branch 'fix/biometrics-login' into 'dev'

Fixes biometric authentication

See merge request elixxir/client-ios!85
parents 8f944118 ba81fd20
No related branches found
No related tags found
1 merge request!85Fixes biometric authentication
......@@ -27,7 +27,7 @@ public final class LaunchController: UIViewController {
.statePublisher
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
guard $0.shouldPushChats == false else {
guard $0.shouldPushEndDestination != .some(.chats) else {
guard $0.shouldShowTerms == false else {
navigator.perform(PresentTermsAndConditions(replacing: true, on: navigationController!))
return
......@@ -39,7 +39,7 @@ public final class LaunchController: UIViewController {
navigator.perform(PresentChatList(on: navigationController!))
return
}
guard $0.shouldPushOnboarding == false else {
guard $0.shouldPushEndDestination != .some(.onboarding) else {
navigator.perform(PresentOnboardingStart(on: navigationController!))
return
}
......
......@@ -29,6 +29,10 @@ import class XXClient.Cancellable
import PulseLogHandler
final class LaunchViewModel {
enum Destination {
case chats, onboarding
}
struct UpdateModel {
let content: String
let urlString: String
......@@ -39,9 +43,8 @@ final class LaunchViewModel {
struct ViewState {
var shouldShowTerms = false
var shouldPushChats = false
var shouldOfferUpdate: UpdateModel?
var shouldPushOnboarding = false
var shouldPushEndDestination: Destination?
}
@Dependency(\.app.log) var log
......@@ -202,21 +205,41 @@ extension LaunchViewModel {
try dummyTrafficManager.setStatus(dummyTrafficOn)
let endDestination: Destination
if messenger.isLoggedIn() == false {
if try messenger.isRegistered() {
try messenger.logIn()
hudManager.hide()
stateSubject.value.shouldPushChats = true
endDestination = .chats
} else {
try? sftpManager.unlink()
try? dropboxManager.unlink()
hudManager.hide()
stateSubject.value.shouldPushOnboarding = true
endDestination = .onboarding
}
} else {
endDestination = .chats
}
defer {
hudManager.hide()
stateSubject.value.shouldPushChats = true
if endDestination == .chats {
if isBiometricsOn, permissions.biometrics.status() {
permissions.biometrics.request { [weak self] granted in
guard let self else { return }
if granted {
self.stateSubject.value.shouldPushEndDestination = .chats
} else {
// TODO: A fallback state for failing biometrics
}
}
} else {
stateSubject.value.shouldPushEndDestination = .chats
}
} else {
stateSubject.value.shouldPushEndDestination = .onboarding
}
}
if !messenger.isBackupRunning() {
try? messenger.resumeBackup()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment