mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Refactoring
This commit is contained in:
47
submodules/TelegramCore/Sources/State/AccountState.swift
Normal file
47
submodules/TelegramCore/Sources/State/AccountState.swift
Normal file
@@ -0,0 +1,47 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
import SyncCore
|
||||
|
||||
extension UnauthorizedAccountTermsOfService {
|
||||
init?(apiTermsOfService: Api.help.TermsOfService) {
|
||||
switch apiTermsOfService {
|
||||
case let .termsOfService(_, id, text, entities, minAgeConfirm):
|
||||
let idData: String
|
||||
switch id {
|
||||
case let .dataJSON(data):
|
||||
idData = data
|
||||
}
|
||||
self.init(id: idData, text: text, entities: messageTextEntitiesFromApiEntities(entities), ageConfirmation: minAgeConfirm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SentAuthorizationCodeType {
|
||||
init(apiType: Api.auth.SentCodeType) {
|
||||
switch apiType {
|
||||
case let .sentCodeTypeApp(length):
|
||||
self = .otherSession(length: length)
|
||||
case let .sentCodeTypeSms(length):
|
||||
self = .sms(length: length)
|
||||
case let .sentCodeTypeCall(length):
|
||||
self = .call(length: length)
|
||||
case let .sentCodeTypeFlashCall(pattern):
|
||||
self = .flashCall(pattern: pattern)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AuthorizationCodeNextType {
|
||||
init(apiType: Api.auth.CodeType) {
|
||||
switch apiType {
|
||||
case .codeTypeSms:
|
||||
self = .sms
|
||||
case .codeTypeCall:
|
||||
self = .call
|
||||
case .codeTypeFlashCall:
|
||||
self = .flashCall
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user