Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void confirmCode(String confirmationCode) {
- if (state is! EnteringSmsCodeRegistration) return;
- EnteringSmsCodeRegistration currentState = state;
- RegistrationSession currentSession = currentState.registrationSession;
- emit(ProcessingEnteredSmsCode(
- phone: currentState.phone,
- region: currentState.region,
- password: currentState.password,
- registrationSession: currentSession,
- secondToRequest: currentState.secondToRequest,
- ));
- _confirmCode(currentSession.sessionId, confirmationCode).then(
- (confirmCodeResult) {
- confirmCodeResult.process(
- (value) {
- _timerCode.cancel();
- emit(EnteringUserInformation(
- phone: currentState.phone,
- region: currentState.region,
- password: currentState.password,
- registrationSession: currentSession,
- ));
- },
- (exception) {
- if (exception is InvalidSmsCodeException) {
- var previousState;
- if (state is! ProcessingEnteredSmsCode && state is! EnteringSmsCodeRegistration) return;
- previousState = state;
- emit(EnteringSmsCodeRegistration(
- phone: previousState.phone,
- region: previousState.region,
- password: previousState.password,
- registrationSession:
- currentSession.copy(confirmationAttemptsLeft: currentSession.confirmationAttemptsLeft - 1),
- secondToRequest: previousState.secondToRequest,
- ));
- if (state is! EnteringSmsCodeRegistration) return;
- currentState = state;
- currentSession = currentState.registrationSession;
- if (currentSession.confirmationAttemptsLeft < 1) {
- _timerCode.cancel();
- _timerRegistration.cancel();
- emit(
- EnteringRegistrationInfo(
- phone: currentState.phone,
- region: currentState.region,
- password: currentState.password,
- ),
- );
- }
- } else {
- // TODO
- }
- },
- );
- },
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement