no message

This commit is contained in:
Peter
2017-03-21 19:58:11 +03:00
parent c5d34b17f0
commit 2707eea1c3
111 changed files with 7305 additions and 856 deletions

View File

@@ -192,6 +192,53 @@ public final class AuthorizationSequenceController: NavigationController {
return controller
}
private func signUpController(firstName: String, lastName: String) -> AuthorizationSequenceSignUpController {
var currentController: AuthorizationSequenceSignUpController?
for c in self.viewControllers {
if let c = c as? AuthorizationSequenceSignUpController {
currentController = c
break
}
}
let controller: AuthorizationSequenceSignUpController
if let currentController = currentController {
controller = currentController
} else {
controller = AuthorizationSequenceSignUpController()
controller.signUpWithName = { [weak self, weak controller] firstName, lastName in
if let strongSelf = self {
controller?.inProgress = true
strongSelf.actionDisposable.set((signUpWithName(account: strongSelf.account, firstName: firstName, lastName: lastName) |> deliverOnMainQueue).start(error: { error in
Queue.mainQueue().async {
if let controller = controller {
controller.inProgress = false
let text: String
switch error {
case .limitExceeded:
text = "You have entered invalid password too many times. Please try again later."
case .codeExpired:
text = "Authorization code has expired. Please start again."
case .invalidFirstName:
text = "Please enter valid first name"
case .invalidLastName:
text = "Please enter valid last name"
case .generic:
text = "An error occured. Please try again later."
}
controller.present(standardTextAlertController(title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: "OK", action: {})]), in: .window)
}
}
}))
}
}
}
controller.updateData(firstName: firstName, lastName: lastName)
return controller
}
private func updateState(state: Coding?) {
if let state = state as? UnauthorizedAccountState {
switch state.contents {
@@ -206,9 +253,11 @@ public final class AuthorizationSequenceController: NavigationController {
self.setViewControllers([self.splashController(), self.codeEntryController(number: number, type: type, nextType: nextType, timeout: timeout)], animated: !self.viewControllers.isEmpty)
case let .passwordEntry(hint):
self.setViewControllers([self.splashController(), self.passwordEntryController(hint: hint)], animated: !self.viewControllers.isEmpty)
case let .signUp(_, _, _, firstName, lastName):
self.setViewControllers([self.splashController(), self.signUpController(firstName: firstName, lastName: lastName)], animated: !self.viewControllers.isEmpty)
}
} else if let _ = state as? AuthorizedAccountState {
self._authorizedAccount.set(accountWithId(self.account.id, appGroupPath: self.account.appGroupPath, testingEnvironment: self.account.testingEnvironment) |> mapToSignal { account -> Signal<Account, NoError> in
self._authorizedAccount.set(accountWithId(apiId: self.account.apiId, id: self.account.id, appGroupPath: self.account.appGroupPath, testingEnvironment: self.account.testingEnvironment) |> mapToSignal { account -> Signal<Account, NoError> in
if case let .right(authorizedAccount) = account {
return .single(authorizedAccount)
} else {